[PATCH 0/1] MR10201: dwrite: Add locales to locale list.
The Chinese version of the Noto Sans CJK font was being chosen despite being in Japanese locale. Specifically, Noto Sans CJK SC was used for 0x5c06 instead of Noto Sans CJK JP. The locale list for the system fallback collection was just the neutral locale. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10201
From: Daniel Lehman <dlehman25@gmail.com> Existing helper font_fallback_get_locale returns neutral locale if the exact name is not found. This is ok when searching for the font fallback, but shortcuts the adding of locale when building the font fallback collection. --- dlls/dwrite/analyzer.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c index 8548d8515fb..91ce6fd92be 100644 --- a/dlls/dwrite/analyzer.c +++ b/dlls/dwrite/analyzer.c @@ -531,6 +531,19 @@ static HRESULT fallback_locale_add_mapping(struct fallback_locale *locale, size_ return S_OK; } +static struct fallback_locale * font_fallback_get_locale_exact(const struct list *locales, + const WCHAR *locale_name) +{ + struct fallback_locale *locale; + + LIST_FOR_EACH_ENTRY(locale, locales, struct fallback_locale, entry) + { + if (!wcsicmp(locale->name, locale_name)) return locale; + } + + return NULL; +} + /* TODO: potentially needs improvement to consider partially matching locale names. */ static struct fallback_locale * font_fallback_get_locale(const struct list *locales, const WCHAR *locale_name) @@ -2764,7 +2777,7 @@ static struct fallback_locale * fallback_builder_add_locale(struct dwrite_fontfa struct fallback_locale *locale; if (!locale_name) locale_name = L""; - if ((locale = font_fallback_get_locale(&builder->data.locales, locale_name))) return locale; + if ((locale = font_fallback_get_locale_exact(&builder->data.locales, locale_name))) return locale; if (!(locale = calloc(1, sizeof(*locale)))) return NULL; lstrcpynW(locale->name, locale_name, ARRAY_SIZE(locale->name)); list_add_tail(&builder->data.locales, &locale->entry); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10201
What was the exact sequence of calls? Is this about system or custom fallback? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10201#note_130703
Is this about system or custom fallback?
system
What was the exact sequence of calls?
this is a narrowed-ish down test: https://gitlab.winehq.org/dlehman25/wine/-/compare/master...dwrite-locales-t... -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10201#note_130848
On Sat Feb 28 23:35:14 2026 +0000, Daniel Lehman wrote:
Is this about system or custom fallback? system What was the exact sequence of calls? this is a narrowed-ish down test: https://gitlab.winehq.org/dlehman25/wine/-/compare/master...dwrite-locales-t... I see, it's worse than I thought. This permissive matching prevents adding new entries. Thanks a lot for the test.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10201#note_131069
Nikolay Sivov (@nsivov) commented about dlls/dwrite/analyzer.c:
return S_OK; }
+static struct fallback_locale * font_fallback_get_locale_exact(const struct list *locales, + const WCHAR *locale_name) +{ + struct fallback_locale *locale; + + LIST_FOR_EACH_ENTRY(locale, locales, struct fallback_locale, entry) + { + if (!wcsicmp(locale->name, locale_name)) return locale; + } + + return NULL; +}
This is fine but we don't need to duplicate. Could you add a bool flag to the font_fallback_get_locale(), either 'use_neutral' or, an opposite to it, 'exact_match' to block second condition. P.S. stdbool.h is already included and used, so "bool" is good for internal things. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10201#note_131070
participants (3)
-
Daniel Lehman -
Daniel Lehman (@dlehman25) -
Nikolay Sivov (@nsivov)