summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2015-08-09 00:59:31 +0200
committerBehdad Esfahbod <behdad@behdad.org>2016-03-08 13:39:05 -0800
commit27d61f1ddcda5543e9c6440a0f8794caa0b1eac7 (patch)
treea36eacced51e66fe600a07bc8a05c76f6d39fc2e /src
parent00c8408c6a82a79388f8119c4afce6e721b693f7 (diff)
[GX] Enumerate all named-instances in TrueType GX fonts
Diffstat (limited to 'src')
-rw-r--r--src/fcdir.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/fcdir.c b/src/fcdir.c
index 40d8071b..81c98b65 100644
--- a/src/fcdir.c
+++ b/src/fcdir.c
@@ -72,14 +72,16 @@ FcFileScanFontConfig (FcFontSet *set,
FT_Face face;
FcPattern *font;
FcBool ret = FcTrue;
- int id;
int num_faces = 0;
+ int num_instances = 0;
+ int face_num = 0;
+ int instance_num = 0;
+ int id;
const FcChar8 *sysroot = FcConfigGetSysRoot (config);
if (FT_Init_FreeType (&ftLibrary))
return FcFalse;
- id = 0;
do
{
font = 0;
@@ -92,9 +94,11 @@ FcFileScanFontConfig (FcFontSet *set,
fflush (stdout);
}
+ id = ((instance_num << 16) + face_num);
if (FT_New_Face (ftLibrary, (char *) file, id, &face))
return FcFalse;
num_faces = face->num_faces;
+ num_instances = face->style_flags >> 16;
font = FcFreeTypeQueryFace (face, file, id, blanks);
FT_Done_Face (face);
@@ -152,8 +156,15 @@ FcFileScanFontConfig (FcFontSet *set,
}
else
ret = FcFalse;
- id++;
- } while (font && ret && id < num_faces);
+
+ if (instance_num < num_instances)
+ instance_num++;
+ else
+ {
+ face_num++;
+ instance_num = 0;
+ }
+ } while (font && ret && face_num < num_faces);
FT_Done_FreeType (ftLibrary);