<DIV><BR>>hi</DIV>
<DIV> 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.</DIV>
<DIV>int _tmain(int argc, _TCHAR* argv[])<BR>{</DIV>
<DIV>FILE *fp_glyph;<BR> if ((fp_glyph=fopen("example.bin","rb"))==NULL)//in this example 'example.bin' only one group data<BR> {<BR> printf("open file is error glyphs.txt");<BR> }<BR> fseek(fp_glyph,0,SEEK_SET);<BR> fseek(fp_glyph,0,SEEK_END);<BR> int size=ftell(fp_glyph);<BR> fseek(fp_glyph,0,SEEK_SET);</DIV>
<DIV><BR> unsigned char *datas=(unsigned char *)malloc(size);<BR> memset(datas,0,size);<BR> fread(datas,1,size,fp_glyph);<BR> fclose(fp_glyph);</DIV>
<DIV><BR> readAndAnalyse *temp_read=new readAndAnalyse(); //analyse the data collect from datas<BR> temp_read->addFontGlyphs('a',3,datas,size);//add the datas to readAndAnalyse class's property </DIV>
<DIV> temp_read->addFontGlyphs('b',3,datas,size);//iteration for getting multi-datas </DIV>
<DIV> temp_read->addFontGlyphs('c',3,datas,size);//iteration for getting multi-datas<BR> temp_read->addFontGlyphs(-1,0,NULL,0);//this line use to store the terminative flag</DIV>
<DIV> delete datas;</DIV>
<DIV> cairo_surface_t *surface;<BR> cairo_t *cr;</DIV>
<DIV> surface = cairo_pdf_surface_create ("hell.pdf",5000,5000);<BR> cr = cairo_create (surface);<BR> newFont *myfont=new newFont();//create font_face and draw text<BR> cairo_font_face_t *font_face;<BR> myfont->test_user_font_face_create(&font_face,temp_read->getFontGlyphs());//create the font_face </DIV>
<DIV> delete temp_read; <BR> cairo_set_source_rgb (cr, 1, 1, 1);<BR> cairo_paint (cr);<BR> myfont->test_draw(font_face,cr,"abcdefghi");//draw text<BR> delete myfont;<BR> cairo_font_face_destroy(font_face);<BR> cairo_destroy(cr);<BR> cairo_surface_destroy(surface);<BR> return 0;<BR>}<BR>In the main funtion there are two Class --readAndAnalyse and newFont </DIV>
<DIV>readAndAnalyse class main aim is get Glyphs datas from "example.bin" and store the datas in one class's property.</DIV>
<DIV>newFont class main aim is create the Font_face and draw_text</DIV>
<DIV>the attachment is the Font_face's cpp file.</DIV>
<DIV>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.</DIV>
<DIV>thank you!</DIV>
<DIV> </DIV>
<DIV>>>fenglunkuo</DIV>
<DIV> </DIV><br><!-- footer --><br><span title="neteasefooter"/><hr/>
<a href="http://qiye.163.com/?ft=3">网易企业邮,商务邮箱专家</a>
</span>