bob.c (988B)
1 #include <graphite2/Segment.h> 2 #include <stdio.h> 3 4 int main(int argc, char *argv[]) 5 { 6 int rtl = 0; /*are we rendering right to left? probably not */ 7 int pointsize = 12; /*point size in points */ 8 int dpi = 96; /*work with this many dots per inch */ 9 char *pError; /*location of faulty utf-8 */ 10 gr_font *font = NULL; 11 size_t numCodePoints = 0; 12 gr_segment *seg = NULL; 13 const gr_slot *s; 14 gr_face *face = gr_make_file_face(argv[1], 0); 15 if (!face) return 1; 16 font = gr_make_font(pointsize * dpi / 72.0f, face); 17 if (!font) return 2; 18 numCodePoints = gr_count_unicode_characters(gr_utf8, argv[2], NULL, (const void **)(&pError)); 19 if (pError) return 3; 20 seg = gr_make_seg(font, face, 0, 0, gr_utf8, argv[2], numCodePoints, rtl); 21 if (!seg) return 3; 22 for (s = gr_seg_first_slot(seg); s; s = gr_slot_next_in_segment(s)) 23 printf("%d %d(%f,%f) ", gr_slot_gid(s), gr_slot_origin_X(s), gr_slot_origin_Y(s)); 24 gr_seg_destroy(seg); 25 gr_font_destroy(font); 26 gr_face_destroy(face); 27 return 0; 28 }