diff options
Diffstat (limited to 'fc-query/fc-query.c')
-rw-r--r-- | fc-query/fc-query.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/fc-query/fc-query.c b/fc-query/fc-query.c index 9bd39805..842a8b6f 100644 --- a/fc-query/fc-query.c +++ b/fc-query/fc-query.c @@ -98,8 +98,11 @@ usage (char *program, int error) int main (int argc, char **argv) { + FT_Library ftLibrary; int index_set = 0; int set_index = 0; + int set_face_num = 0; + int set_instance_num = 0; int ignore_blanks = 0; FcChar8 *format = NULL; FcBlanks *blanks = NULL; @@ -143,19 +146,38 @@ main (int argc, char **argv) if (i == argc) usage (argv[0], 1); + if (FT_Init_FreeType (&ftLibrary)) + return 1; + if (!ignore_blanks) blanks = FcConfigGetBlanks (NULL); for (; i < argc; i++) { - int index; - int count = 0; - - index = set_index; + FT_Face face; + int num_faces = 0; + int num_instances = 0; + int face_num = 0; + int instance_num = 0; + int id; + + if (index_set) + { + face_num = set_face_num = set_index & 0xFFFF; + instance_num = set_instance_num = set_index >> 16; + } do { FcPattern *pat; - pat = FcFreeTypeQuery ((FcChar8 *) argv[i], index, blanks, &count); + id = ((instance_num << 16) + face_num); + printf("id %d\n", id); + if (FT_New_Face (ftLibrary, argv[i], id, &face)) + break; + num_faces = face->num_faces; + num_instances = face->style_flags >> 16; + pat = FcFreeTypeQueryFace (face, (const FcChar8 *) argv[i], id, blanks); + FT_Done_Face (face); + if (pat) { if (format) @@ -178,15 +200,21 @@ main (int argc, char **argv) } else { - fprintf (stderr, "Can't query face %d of font file %s\n", - index, argv[i]); + fprintf (stderr, "Can't query face %d of font file %s\n", id, argv[i]); err = 1; } - index++; - } while (!index_set && index < count); + if (instance_num < num_instances && !set_instance_num) + instance_num++; + else + { + face_num++; + instance_num = 0; + } + } while (!err && (!index_set || face_num == set_face_num) && face_num < num_faces); } + FT_Done_FreeType (ftLibrary); FcFini (); return err; } |