Index: work/util/ttf2lht/ttf2lht.c =================================================================== --- work/util/ttf2lht/ttf2lht.c (revision 18920) +++ work/util/ttf2lht/ttf2lht.c (revision 18921) @@ -2,10 +2,75 @@ #include #include #include +#include +#include FT_Library library; FT_Face face; +const char *int_errtab[] = { + "success", + "Need an outline font" +}; + +int stroke_move_to(const FT_Vector *to, void *fp) +{ + printf("# move to\n"); + return 0; +} + +int stroke_line_to(const FT_Vector *to, void *fp) +{ + printf("# line to\n"); + return 0; +} + +int stroke_conic_to(const FT_Vector *control, const FT_Vector *to, void *fp) +{ + printf("# conic to\n"); + return 0; +} + +int stroke_cubic_to(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, void *fp) +{ + printf("# cubic to\n"); + return 0; +} + + +static const FT_Outline_Funcs funcs = { + stroke_move_to, + stroke_line_to, + stroke_conic_to, + stroke_cubic_to, + 0, + 0 +}; + + +FT_Error dump(FT_ULong chr) +{ + FT_Error err; + FT_Glyph gly; + FT_OutlineGlyph ol; + + // load glyph + err = FT_Load_Glyph(face, FT_Get_Char_Index(face, chr), FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE); + if (err != 0) + return err; + + FT_Get_Glyph(face->glyph, &gly); + ol = (FT_OutlineGlyph)gly; + if (face->glyph->format != ft_glyph_format_outline) + return -1; + + err = FT_Outline_Decompose(&(ol->outline), &funcs, NULL); + if (err != 0) + return err; + + return 0; +} + int main(int argc, char *argv[]) { char *fontname = "FreeMono.ttf"; @@ -41,7 +106,14 @@ for(chr = FT_Get_First_Char(face, &idx); idx != 0; chr = FT_Get_Next_Char(face, chr, &idx)) { if ((chr <= 32) || (chr >= 127)) /* accept 7 bit printable ASCII only */ continue; - printf("chr=%ld\n", chr); + printf("# chr=%ld\n", chr); + errnum = dump(chr); + if (errnum != 0) { + if (errnum > 0) + fprintf(stderr, "dump: %s\n", ft_errtab[errnum].errstr); + else + fprintf(stderr, "dump: %s\n", int_errtab[-errnum]); + } } FT_Done_Face(face);