diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2022-12-14 12:56:05 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2022-12-14 13:10:27 +0800 |
commit | c050fe202f1ef4657e64d48d363188240774f90f (patch) | |
tree | e19d0b2ecf417667fe1bec7a79603665c2cebf40 /pango/pangowin32-fontmap.c | |
parent | c5b5d53ae90e15c0ba74b75f08a39fa4098a03f7 (diff) | |
download | pango-fix-partially-720.tar.gz |
pangowin32-fontmap.c: Allow some support for loading custom fontsfix-partially-720
Previously, when using GDI, we are able to add custom fonts to the system font
collection using AddFontResource()/AddFontResourceEx(), but this is not enough
as we transition to DirectWrite.
Allow some support for this for people that are using AddFontResource() (but
not yet AddFontResourceEx()), by using the GDI interop support in DirectWrite.
Let people know that currently AddFontResource() should be used for the moment
for this support to work, not AddFontResourceEx().
Diffstat (limited to 'pango/pangowin32-fontmap.c')
-rw-r--r-- | pango/pangowin32-fontmap.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c index 4cc95787..9b8f6e4b 100644 --- a/pango/pangowin32-fontmap.c +++ b/pango/pangowin32-fontmap.c @@ -193,7 +193,10 @@ pango_win32_inner_enum_proc (LOGFONTW *lfp, * Asian fonts with @ prepended to their name, ignore them. */ if (lfp->lfFaceName[0] != '@') - pango_win32_insert_font (win32fontmap, lfp, NULL, FALSE); + { + gpointer dwrite_font = pango_win32_logfontw_get_dwrite_font (lfp); + pango_win32_insert_font (win32fontmap, lfp, dwrite_font, FALSE); + } return 1; } @@ -212,17 +215,24 @@ pango_win32_enum_proc (LOGFONTW *lfp, { LOGFONTW lf; struct EnumProcData *data = (struct EnumProcData *) lParam; + PangoWin32FontMap *map = data->font_map; PING (("%S: %lu %lx", lfp->lfFaceName, fontType, metrics->ntmFlags)); - /* Do not enum Type-1 fonts */ - if (fontType == TRUETYPE_FONTTYPE || metrics->ntmFlags & NTM_PS_OPENTYPE) + /* Do not enum Type-1 fonts, and ignore any fonts in the system font + * collection that was previously picked up by DirectWrite + * (IDWriteFactory->GetSystemFontCollection() via + * pango_win32_dwrite_font_map_populate()) + */ + + if (!g_hash_table_lookup (map->fonts, lfp) && + (fontType == TRUETYPE_FONTTYPE || metrics->ntmFlags & NTM_PS_OPENTYPE)) { lf = *lfp; EnumFontFamiliesExW (data->hdc, &lf, (FONTENUMPROCW) pango_win32_inner_enum_proc, - (LPARAM) data->font_map, 0); + (LPARAM) map, 0); } return 1; @@ -720,7 +730,6 @@ _pango_win32_font_map_init (PangoWin32FontMap *win32fontmap) pango_win32_dwrite_font_map_populate (win32fontmap); -#if 0 /* XXX: Implement fallback mode to GDI? */ memset (&logfont, 0, sizeof (logfont)); logfont.lfCharSet = DEFAULT_CHARSET; @@ -730,7 +739,6 @@ _pango_win32_font_map_init (PangoWin32FontMap *win32fontmap) EnumFontFamiliesExW (hdc, &logfont, (FONTENUMPROCW) pango_win32_enum_proc, (LPARAM) &enum_proc_data, 0); -#endif g_hash_table_foreach (win32fontmap->families, synthesize_foreach, win32fontmap); |