[vlc-commits] freetype: translate generic families for CoreText
Francois Cartegnie
git at videolan.org
Tue Jul 21 16:07:22 CEST 2020
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jul 9 18:23:24 2020 +0200| [cb23a11dd3d2d53ea15392cb7b05286839a489e2] | committer: Francois Cartegnie
freetype: translate generic families for CoreText
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cb23a11dd3d2d53ea15392cb7b05286839a489e2
---
modules/text_renderer/freetype/fonts/darwin.c | 37 +++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/modules/text_renderer/freetype/fonts/darwin.c b/modules/text_renderer/freetype/fonts/darwin.c
index 9d99bea30a..238a369e56 100644
--- a/modules/text_renderer/freetype/fonts/darwin.c
+++ b/modules/text_renderer/freetype/fonts/darwin.c
@@ -80,12 +80,47 @@ static void addNewFontToFamily(vlc_font_select_t *fs, CTFontDescriptorRef iter,
CFRelease(fontTraits);
}
+const struct
+{
+ const char *psz_generic;
+ const char *psz_local;
+}
+CoreTextGenericMapping[] =
+{
+ { "cursive", "Apple Chancery" },
+// { "emoji", "" },
+// { "fangsong", "" },
+ { "fantasy", "Papyrus" },
+ { "monospace", "Courier" },
+ { "sans", "Helvetica" },
+ { "sans-serif","Helvetica" },
+ { "serif", "Times" },
+ { "system-ui", ".AppleSystemUIFont" },
+// { "math", "" },
+// { "ui-monospace", "" },
+// { "ui-rounded", "" },
+// { "ui-serif", "" },
+// { "ui-sans-serif", "" },
+};
+
+const char *CoreText_TranslateGenericFamily(const char *psz_family)
+{
+ for( size_t i=0; i<ARRAY_SIZE(CoreTextGenericMapping); i++ )
+ {
+ if( !strcasecmp( CoreTextGenericMapping[i].psz_generic, psz_family ) )
+ return CoreTextGenericMapping[i].psz_local;
+ }
+ return psz_family;
+}
+
const vlc_family_t *CoreText_GetFamily(vlc_font_select_t *fs, const char *psz_family)
{
if (unlikely(psz_family == NULL)) {
return NULL;
}
+ psz_family = CoreText_TranslateGenericFamily(psz_family);
+
char *psz_lc = ToLower(psz_family);
if (unlikely(!psz_lc)) {
return NULL;
@@ -189,6 +224,8 @@ vlc_family_t *CoreText_GetFallbacks(vlc_font_select_t *fs, const char *psz_famil
return NULL;
}
+ psz_family = CoreText_TranslateGenericFamily(psz_family);
+
vlc_family_t *p_family = NULL;
CFStringRef postScriptFallbackFontname = NULL;
CTFontDescriptorRef fallbackFontDescriptor = NULL;
More information about the vlc-commits
mailing list