[Fontconfig] fontconfig: Branch 'main'
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Aug 25 06:23:38 UTC 2023
doc/fontconfig-user.sgml | 3 ++-
src/fcfreetype.c | 17 ++++++++++++++---
2 files changed, 16 insertions(+), 4 deletions(-)
New commits:
commit e0eb855462791cbe217adc368d156733b2b2c13a
Author: Khaled Hosny <khaled at libreoffice.org>
Date: Thu Aug 24 14:11:26 2023 +0300
Detect standalone CFF fonts for FC_FONT_WRAPPER
FreeType will return CFF for both SFNT fonts with CFF table as well as
standalone CFF fonts, but applications might want to support the former
and not the later, so now FC_FONT_WRAPPER makes the distinction more
clear.
diff --git a/doc/fontconfig-user.sgml b/doc/fontconfig-user.sgml
index f24794d..77654ac 100644
--- a/doc/fontconfig-user.sgml
+++ b/doc/fontconfig-user.sgml
@@ -149,7 +149,8 @@ order Int Order number of the font
desktop String Current desktop name
namedinstance Bool Whether font is a named instance
fontwarapper String The font wrapper format, current values are WOFF, WOFF2,
- and SFNT for any other SFNT font.
+ SFNT for any other SFNT font, and CFF for standalone
+ CFF fonts.
</programlisting>
</refsect2>
<refsect2>
diff --git a/src/fcfreetype.c b/src/fcfreetype.c
index 27b72ea..17523fd 100644
--- a/src/fcfreetype.c
+++ b/src/fcfreetype.c
@@ -2164,6 +2164,9 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
if (!FcPatternObjectAddBool (pat, FC_ANTIALIAS_OBJECT, FcFalse))
goto bail2;
}
+
+ FcChar8* wrapper = NULL;
+
#if HAVE_FT_GET_X11_FONT_FORMAT
/*
* Use the (not well documented or supported) X-specific function
@@ -2172,18 +2175,25 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
{
const char *font_format = FT_Get_X11_Font_Format (face);
if (font_format)
+ {
if (!FcPatternObjectAddString (pat, FC_FONTFORMAT_OBJECT, (FcChar8 *) font_format))
goto bail2;
+
+ /* If this is not a SFNT font and format is CFF, then it is a standlone CFF font */
+ if (!FT_IS_SFNT (face) && !strcmp (font_format, "CFF"))
+ wrapper = (FcChar8*) "CFF";
+ }
}
#endif
+
if (!FcPatternObjectAddBool (pat, FC_NAMED_INSTANCE_OBJECT, !!(id > 0xffff)))
goto bail2;
- if (face->face_flags & FT_FACE_FLAG_SFNT)
+ if (FT_IS_SFNT (face))
{
/* If this is an SFNT wrapper, try to sniff the SFNT tag which is the
* first 4 bytes, to see if it is a WOFF or WOFF2 wrapper. */
- FcChar8* wrapper = (FcChar8*) "SFNT";
+ wrapper = (FcChar8*) "SFNT";
char buf[4];
int fd = FcOpen ((char *) file, O_RDONLY);
@@ -2198,10 +2208,11 @@ FcFreeTypeQueryFaceInternal (const FT_Face face,
}
}
close (fd);
+ }
+ if (wrapper)
if (!FcPatternObjectAddString (pat, FC_FONT_WRAPPER_OBJECT, wrapper))
goto bail2;
- }
/*
* Drop our reference to the charset
More information about the Fontconfig
mailing list