From: समीर सिंह Sameer Singh <lumarzeli30@gmail.com> This would allow Uniscribe to dynamically populate script based fallback mappings in the registry based on the system's available fonts. --- dlls/win32u/freetype.c | 40 +++++++++++++++++++++++++++++++++++++ dlls/win32u/ntgdi_private.h | 1 + 2 files changed, 41 insertions(+) diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c index a660b166a0f..db4c96eabf9 100644 --- a/dlls/win32u/freetype.c +++ b/dlls/win32u/freetype.c @@ -131,6 +131,10 @@ MAKE_FUNCPTR(FcDefaultSubstitute); MAKE_FUNCPTR(FcFontList); MAKE_FUNCPTR(FcFontMatch); MAKE_FUNCPTR(FcFontSetDestroy); +MAKE_FUNCPTR(FcCharSetAddChar); +MAKE_FUNCPTR(FcCharSetCreate); +MAKE_FUNCPTR(FcCharSetDestroy); +MAKE_FUNCPTR(FcPatternAddCharSet); MAKE_FUNCPTR(FcInit); MAKE_FUNCPTR(FcPatternAddString); MAKE_FUNCPTR(FcPatternCreate); @@ -1188,6 +1192,37 @@ static FcPattern *create_family_pattern( const char *name, FcPattern **cached ) return ret; } +static void fontconfig_get_default_font_for_char( DWORD ch, WCHAR *font_name ) +{ + FcPattern *pattern, *match; + FcResult result; + const char *name = NULL; + FcCharSet *charset; + DWORD len; + + *font_name = 0; + + pattern = pFcPatternCreate(); + charset = pFcCharSetCreate(); + pFcCharSetAddChar( charset, ch ); + pFcPatternAddCharSet( pattern, FC_CHARSET, charset ); + pFcCharSetDestroy( charset ); + + pFcConfigSubstitute( NULL, pattern, FcMatchPattern ); + pFcDefaultSubstitute( pattern ); + match = pFcFontMatch( NULL, pattern, &result ); + if (match) + { + if (pFcPatternGetString( match, FC_FAMILY, 0, (FcChar8 **)&name ) == FcResultMatch && name) + { + RtlUTF8ToUnicodeN( font_name, (LF_FACESIZE - 1) * sizeof(WCHAR), &len, name, strlen(name) ); + font_name[len / sizeof(WCHAR)] = 0; + } + pFcPatternDestroy( match ); + } + pFcPatternDestroy( pattern ); +} + static void fontconfig_add_font( FcPattern *pattern, UINT flags ) { const char *unix_name, *format; @@ -1249,6 +1284,10 @@ static void init_fontconfig(void) LOAD_FUNCPTR(FcFontList); LOAD_FUNCPTR(FcFontMatch); LOAD_FUNCPTR(FcFontSetDestroy); + LOAD_FUNCPTR(FcCharSetAddChar); + LOAD_FUNCPTR(FcCharSetCreate); + LOAD_FUNCPTR(FcCharSetDestroy); + LOAD_FUNCPTR(FcPatternAddCharSet); LOAD_FUNCPTR(FcInit); LOAD_FUNCPTR(FcPatternAddString); LOAD_FUNCPTR(FcPatternCreate); @@ -3873,6 +3912,7 @@ static UINT freetype_get_kerning_pairs( struct gdi_font *font, KERNINGPAIR **pai static const struct font_backend_funcs font_funcs = { freetype_load_fonts, + fontconfig_get_default_font_for_char, fontconfig_enum_family_fallbacks, freetype_add_font, freetype_add_mem_font, diff --git a/dlls/win32u/ntgdi_private.h b/dlls/win32u/ntgdi_private.h index fcfbce58fea..ac77d2aa6ed 100644 --- a/dlls/win32u/ntgdi_private.h +++ b/dlls/win32u/ntgdi_private.h @@ -320,6 +320,7 @@ struct gdi_font struct font_backend_funcs { void (*load_fonts)(void); + void (*get_default_font_for_char)( DWORD ch, WCHAR *font_name ); BOOL (*enum_family_fallbacks)( UINT pitch_and_family, int index, WCHAR buffer[LF_FACESIZE] ); INT (*add_font)( const WCHAR *file, UINT flags ); INT (*add_mem_font)( void *ptr, SIZE_T size, UINT flags ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10672