Ejemplo n.º 1
0
int txtbox(char *fntname,float sze,int num,char *txt,float *box,void *data) {
  struct FrameBufferFontDB *fontdb;
  struct FrameBufferFont *fnt;
  int tbox[3];

  fontdb=(struct FrameBufferFontDB *)data;
  if (fontdb==NULL) return -1;
  fnt=FrameBufferFontDBFind(fontdb,fntname,sze);
 
  FrameBufferTextBox(fnt,num,txt,tbox);
  
  box[0]=1.1*tbox[0];
  box[1]=1.1*tbox[1];
  box[2]=1.1*tbox[2];
  return 0;
}
Ejemplo n.º 2
0
int main(int argc,char *argv[]) {

  char *txt={"Hello World"};

  int wdt=400;
  int hgt=400;

  struct FrameBuffer *fb=NULL;

  struct FrameBufferFontDB *fontdb=NULL;
  struct FrameBufferFont *font;

  FILE *fontfp=NULL;
  char *fntdbfname=NULL;

  char *fontname="Times-Roman";
  float fontsize=34.0;

  fntdbfname=getenv("FONTDB");
  fontfp=fopen(fntdbfname,"r");
  if (fontfp !=NULL) {
   fontdb=FrameBufferFontDBLoad(fontfp);
   fclose(fontfp);
  }
 
  if (fontdb==NULL) {
   fprintf(stderr,"Could not load fonts.\n");
   exit(-1);
  }

  
  fb=FrameBufferMake("image",wdt,hgt,24);

  font=FrameBufferFontDBFind(fontdb,fontname,fontsize);


  FrameBufferText(fb,NULL,font,20,200,strlen(txt),
                  txt,0xffffffff,0x0f,1,NULL);

  FrameBufferSavePPM(fb,stdout);
  FrameBufferFree(fb);

  FrameBufferFontDBFree(fontdb);

  return 0;
}