[vlc-commits] freetype: add directwrite generic families mapping
Francois Cartegnie
git at videolan.org
Mon Aug 24 17:39:38 CEST 2020
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Aug 20 00:29:26 2020 +0200| [36248fa92b5215974fa1ce679b731817a43b8afc] | committer: Francois Cartegnie
freetype: add directwrite generic families mapping
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=36248fa92b5215974fa1ce679b731817a43b8afc
---
modules/text_renderer/freetype/fonts/dwrite.cpp | 28 +++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/modules/text_renderer/freetype/fonts/dwrite.cpp b/modules/text_renderer/freetype/fonts/dwrite.cpp
index 3072ad1293..0b8250b4be 100644
--- a/modules/text_renderer/freetype/fonts/dwrite.cpp
+++ b/modules/text_renderer/freetype/fonts/dwrite.cpp
@@ -96,6 +96,32 @@ struct dw_sys_t
}
};
+static const struct
+{
+ const char *psz_generic;
+ const char *psz_local;
+}
+DWriteGenericMapping[] =
+{
+ { "cursive", "comic sans ms" },
+ { "fantasy", "impact" },
+ { "monospace", "courier new" },
+ { "sans", "arial" },
+ { "sans-serif","arial" },
+ { "serif", "times new roman" },
+ { "system-ui", "ms ui gothic" },
+};
+
+static const char *DWrite_TranslateGenericFamily( const char *psz_family )
+{
+ for( size_t i=0; i<ARRAY_SIZE(DWriteGenericMapping); i++ )
+ {
+ if( !strcasecmp( DWriteGenericMapping[i].psz_generic, psz_family ) )
+ return DWriteGenericMapping[i].psz_local;
+ }
+ return psz_family;
+}
+
static inline void AppendFamily( vlc_family_t **pp_list, vlc_family_t *p_family )
{
while( *pp_list )
@@ -583,6 +609,8 @@ extern "C" int DWrite_GetFamily( vlc_font_select_t *fs, const char *psz_lcname,
UINT32 i_index;
BOOL b_exists = false;
+ psz_lcname = DWrite_TranslateGenericFamily( psz_lcname );
+
vlc_family_t *p_family =
( vlc_family_t * ) vlc_dictionary_value_for_key( &fs->family_map, psz_lcname );
More information about the vlc-commits
mailing list