fontconfig: Branch 'master'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 fc-query/Makefile.am |    2 +-
 fc-query/fc-query.c  |   46 +++++++++++++++++++++++++++++++++++++---------
 2 files changed, 38 insertions(+), 10 deletions(-)

New commits:
commit e5a51c899480c3bd99c36e49d1c24932f6a08810
Author: Behdad Esfahbod <behdad@xxxxxxxxxx>
Date:   Tue Aug 1 14:41:02 2017 +0100

    [fc-query] Support listing named instances

diff --git a/fc-query/Makefile.am b/fc-query/Makefile.am
index 73b3f11..6e8ef5c 100644
--- a/fc-query/Makefile.am
+++ b/fc-query/Makefile.am
@@ -41,7 +41,7 @@ EXTRA_DIST=fc-query.sgml $(BUILT_MANS)
 
 CLEANFILES =
 
-fc_query_LDADD = ${top_builddir}/src/libfontconfig.la
+fc_query_LDADD = $(FREETYPE_LIBS) ${top_builddir}/src/libfontconfig.la
 
 if USEDOCBOOK
 
diff --git a/fc-query/fc-query.c b/fc-query/fc-query.c
index 9bd3980..842a8b6 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;
 }
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux