# include "Ximage.h"

int LoadPtext () {
  
  char buffer[256], *c;
  int N, status, Nbytes, mode, size;
  double tmp, L;
  Layout *layout;
  
  layout = &section[TheSection];
  
  fcntl (sock, F_SETFL, !O_NONBLOCK);  
  
  layout[0].Nptext = MAX (layout[0].Nptext, 0);
  N = layout[0].Nptext;
  layout[0].Nptext++;
  REALLOCATE (layout[0].ptext, Label, layout[0].Nptext);

  status = read (sock, buffer, 16); 
  buffer[16] = 0; 
  sscanf (buffer, "%lf", &tmp); 
  L = layout[0].axis[0].dfx;
  layout[0].ptext[N].x = L * (tmp - layout[0].axis[0].min) / (layout[0].axis[0].max - layout[0].axis[0].min) + layout[0].axis[0].fx;

  status = read (sock, buffer, 16); 
  buffer[16] = 0; 
  sscanf (buffer, "%lf", &tmp); 
  L = layout[0].axis[1].dfy;
  layout[0].ptext[N].y = L * (tmp - layout[0].axis[1].min) / (layout[0].axis[1].max - layout[0].axis[1].min) + layout[0].axis[1].fy;

  status = read (sock, buffer, 16); 
  buffer[16] = 0; 
  sscanf (buffer, "%lf", &layout[0].ptext[N].angle); 

  status = read (sock, buffer, 128); 
  buffer[status] = 0; 
  strcpy (layout[0].ptext[N].text, buffer);

  fcntl (sock, F_SETFL, O_NONBLOCK);  
  
  c = GetRotFont (&size);
  layout[0].ptext[N].size = size;
  strcpy (layout[0].ptext[N].font, c);

  DrawPtext (layout);
  
  FlushDisplay ();
  
  return (TRUE);
  
}
