From: समीर सिंह Sameer Singh <lumarzeli30@gmail.com> The previous fallback only consulted the Uniscribe\Fallback registry key and a hardcoded Windows compatible font name. If the hardcoded font was not installed, rendering would fail entirely. The fallback order is now: 1. Uniscribe\Fallback registry key. 2. Hardcoded Windows compatible font name, if installed. 3. Uniscribe\SystemFallback registry key. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=27641 --- dlls/gdi32/uniscribe/usp10.c | 48 ++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/dlls/gdi32/uniscribe/usp10.c b/dlls/gdi32/uniscribe/usp10.c index 43afbaac125..c42327205fb 100644 --- a/dlls/gdi32/uniscribe/usp10.c +++ b/dlls/gdi32/uniscribe/usp10.c @@ -1869,7 +1869,22 @@ static BOOL requires_fallback(HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS *psa, return FALSE; } -static void find_fallback_font(enum usp10_script scriptid, WCHAR *FaceName) +static INT CALLBACK is_font_installed_proc(const LOGFONTW *elf, const TEXTMETRICW *ntm, DWORD type, LPARAM lParam) +{ + return 0; +} + +static BOOL is_font_installed(HDC hdc, const WCHAR *name) +{ + BOOL ret = FALSE; + + if(!EnumFontFamiliesW(hdc, name, is_font_installed_proc, 0)) + ret = TRUE; + + return ret; +} + +static void find_fallback_font(HDC hdc, enum usp10_script scriptid, WCHAR *FaceName) { HKEY hkey; @@ -1880,12 +1895,35 @@ static void find_fallback_font(enum usp10_script scriptid, WCHAR *FaceName) DWORD type; swprintf(value, ARRAY_SIZE(value), L"%x", scriptInformation[scriptid].scriptTag); - if (RegQueryValueExW(hkey, value, 0, &type, (BYTE *)FaceName, &count)) - lstrcpyW(FaceName,scriptInformation[scriptid].fallbackFont); + if (!RegQueryValueExW(hkey, value, 0, &type, (BYTE *)FaceName, &count)) + { + RegCloseKey(hkey); + return; + } RegCloseKey(hkey); } - else + + if (scriptInformation[scriptid].fallbackFont[0] && + is_font_installed(hdc, scriptInformation[scriptid].fallbackFont)) + { lstrcpyW(FaceName,scriptInformation[scriptid].fallbackFont); + return; + } + + if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Uniscribe\\SystemFallback", &hkey)) + { + WCHAR value[10]; + DWORD count = LF_FACESIZE * sizeof(WCHAR); + DWORD type; + + swprintf(value, ARRAY_SIZE(value), L"%x", scriptInformation[scriptid].scriptTag); + if (!RegQueryValueExW(hkey, value, 0, &type, (BYTE *)FaceName, &count)) + { + RegCloseKey(hkey); + return; + } + RegCloseKey(hkey); + } } /*********************************************************************** @@ -2025,7 +2063,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString, GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), & lf); lf.lfCharSet = scriptInformation[analysis->pItem[i].a.eScript].props.bCharSet; lf.lfFaceName[0] = 0; - find_fallback_font(analysis->pItem[i].a.eScript, lf.lfFaceName); + find_fallback_font(hdc, analysis->pItem[i].a.eScript, lf.lfFaceName); if (lf.lfFaceName[0]) { analysis->glyphs[i].fallbackFont = CreateFontIndirectW(&lf); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10672