[cairo] userfont question--there is nothing in the pdf

flk1986 flk1986 at 163.com
Sun Jun 7 19:01:59 PDT 2009


>hi
   I am writting a program which use cairo user font,as a result I want to get 'my font' to draw in pdf,there is my test main funtion.
int _tmain(int argc, _TCHAR* argv[])
{
FILE *fp_glyph;
 if ((fp_glyph=fopen("example.bin","rb"))==NULL)//in this example 'example.bin' only one group data
 {
  printf("open file is error glyphs.txt");
 }
 fseek(fp_glyph,0,SEEK_SET);
 fseek(fp_glyph,0,SEEK_END);
 int size=ftell(fp_glyph);
 fseek(fp_glyph,0,SEEK_SET);

 unsigned char *datas=(unsigned char *)malloc(size);
 memset(datas,0,size);
 fread(datas,1,size,fp_glyph);
 fclose(fp_glyph);

 readAndAnalyse *temp_read=new readAndAnalyse(); //analyse the data collect from datas
 temp_read->addFontGlyphs('a',3,datas,size);//add the datas to readAndAnalyse class's property 
  temp_read->addFontGlyphs('b',3,datas,size);//iteration for getting  multi-datas  
 temp_read->addFontGlyphs('c',3,datas,size);//iteration for getting  multi-datas
 temp_read->addFontGlyphs(-1,0,NULL,0);//this line use to store the terminative flag
 delete datas;
 cairo_surface_t *surface;
 cairo_t *cr;
 surface = cairo_pdf_surface_create ("hell.pdf",5000,5000);
 cr = cairo_create (surface);
 newFont *myfont=new newFont();//create font_face and draw text
 cairo_font_face_t *font_face;
 myfont->test_user_font_face_create(&font_face,temp_read->getFontGlyphs());//create the font_face 
  delete temp_read; 
 cairo_set_source_rgb (cr, 1, 1, 1);
 cairo_paint (cr);
 myfont->test_draw(font_face,cr,"abcdefghi");//draw text
  delete myfont;
  cairo_font_face_destroy(font_face);
 cairo_destroy(cr);
 cairo_surface_destroy(surface);
  return 0;
}
In the main funtion there are two Class --readAndAnalyse and newFont 
readAndAnalyse class main aim is get Glyphs datas from "example.bin" and store the datas in one class's property.
newFont class main aim is create the Font_face and draw_text
the attachment is the Font_face's cpp file.
now my trouble is there is nothing in the "hell.pdf", I found the "newfont_scaled_font_unicode_to_glyph " and "newfont_scaled_font_render_glyph" two callback function were executed only once in debug.
thank you!
 
>>fenglunkuo
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20090608/5818e0a6/attachment.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: newfont.cpp
Url: http://lists.cairographics.org/archives/cairo/attachments/20090608/5818e0a6/attachment.asc 


More information about the cairo mailing list