summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontselect.c
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2021-06-18 01:09:21 +0300
committerOleg Oshmyan <chortos@inbox.lv>2021-07-10 02:36:31 +0300
commitac254eb826ec11e676223a9df560ce246927d063 (patch)
treebebebcfe31853fd25ee213189c21fa01797e555d /libass/ass_fontselect.c
parentc22b6d44ae9cdd7275602f467e70e7503250db52 (diff)
downloadlibass-ac254eb826ec11e676223a9df560ce246927d063.tar.bz2
libass-ac254eb826ec11e676223a9df560ce246927d063.tar.xz
directwrite: better match_fonts via GDI or IDWriteFontSet
CreateFontFromLOGFONT does not actually use GDI's font lookup logic and fails to emulate it faithfully. In particular: it fails to find CFF-outline fonts by PostScript name; it fails to find TrueType fonts by full name on older versions of Windows; it fails to find at least some fonts installed on demand by font managers. When GDI is available, invoke GDI directly. This commit uses EnumFontFamilies, which is almost perfect, except that if the user has two different fonts such that one font's family name equals another's full/PostScript name, this will find only the family name match. To fix this case as well, we'd need to invoke CreateFontIndirect separately for each font request, complete with its weight and slant. This requires larger changes in our fontselect, which this commit does not attempt yet. GDI is not available in WinRT/UWP. On UWP (Windows 10), use the new IDWriteFontSet API to emulate GDI's font lookup as well as we can. In WinRT (Windows 8), we have no choice but to keep using CreateFontFromLOGFONT (unless we go back to loading all fonts eagerly, which we stopped doing for performance reasons). It is the builder's responsibility to avoid linking in Gdi32.lib in WinRT/UWP builds, just as it is to link in Dwrite.lib.
Diffstat (limited to 'libass/ass_fontselect.c')
-rw-r--r--libass/ass_fontselect.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c
index 68a4407..e2d1cb1 100644
--- a/libass/ass_fontselect.c
+++ b/libass/ass_fontselect.c
@@ -1052,7 +1052,13 @@ struct font_constructors font_constructors[] = {
{ ASS_FONTPROVIDER_CORETEXT, &ass_coretext_add_provider, "coretext"},
#endif
#ifdef CONFIG_DIRECTWRITE
- { ASS_FONTPROVIDER_DIRECTWRITE, &ass_directwrite_add_provider, "directwrite"},
+ { ASS_FONTPROVIDER_DIRECTWRITE, &ass_directwrite_add_provider, "directwrite"
+#if ASS_WINAPI_DESKTOP
+ " (with GDI)"
+#else
+ " (without GDI)"
+#endif
+ },
#endif
#ifdef CONFIG_FONTCONFIG
{ ASS_FONTPROVIDER_FONTCONFIG, &ass_fontconfig_add_provider, "fontconfig"},