summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2024-04-09 18:14:15 +0300
committerOleg Oshmyan <chortos@inbox.lv>2024-04-09 18:17:15 +0300
commitd160f8dd08bb7c6d6fe3d798519bf70ca8e6f669 (patch)
treec776ae9a0804b7e6095c5401338f2fbbcca9563a /libass
parent6b895b478d83acc2ffa261c38d3b491b32d46a0b (diff)
downloadlibass-d160f8dd08bb7c6d6fe3d798519bf70ca8e6f669.tar.bz2
libass-d160f8dd08bb7c6d6fe3d798519bf70ca8e6f669.tar.xz
directwrite: verify font name case-insensitively
GDI uses case-insensitive matching. We now request the font's full name, but if it case-insensitively matches the family name, GDI decides that it's a family-name match and returns the family name from GetTextFace instead of the full name we originally requested, which then fails our case-sensitive equality check. An actual example of an affected font is Microsoft YaHei UI (Regular). Its family name is spelt "YaHei" in the name table records marked English and Chinese, but its full name is actually spelt "YaHei" in the English record but "Yahei" in the Chinese one. Thus, on Chinese locales only, requesting "Microsoft YaHei UI" gets "Microsoft Yahei UI" back, fails the check and discards the font, causing the bold version to be used instead, as reported in https://github.com/mpv-player/mpv/issues/13845.
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_directwrite.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libass/ass_directwrite.c b/libass/ass_directwrite.c
index 40a0591..85857bd 100644
--- a/libass/ass_directwrite.c
+++ b/libass/ass_directwrite.c
@@ -751,7 +751,7 @@ static int CALLBACK font_enum_proc(const ENUMLOGFONTW *lpelf,
wchar_t selected_name[LF_FACESIZE];
if (!GetTextFaceW(hdc, LF_FACESIZE, selected_name))
goto cleanup;
- if (wcsncmp(selected_name, lf.lfFaceName, LF_FACESIZE)) {
+ if (_wcsnicmp(selected_name, lf.lfFaceName, LF_FACESIZE)) {
// A different font was selected. This can happen if the requested
// name is subject to charset-specific font substitution while
// EnumFont... enumerates additional charsets contained in the font.