Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
Bahnschrift font introduced in Windows 10 1803 demonstrates this issue.
dlls/dwrite/opentype.c | 15 +++++++++++++-- dlls/dwrite/tests/font.c | 9 +++++++-- 2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index b95083e33a..db44368b2f 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -1736,8 +1736,19 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR * if (!exists) IDWriteLocalizedStrings_FindLocaleName(lfnames, enusW, &index, &exists);
- if (exists) - IDWriteLocalizedStrings_GetString(lfnames, index, lfname, LF_FACESIZE); + if (exists) { + UINT32 length = 0; + WCHAR *nameW; + + IDWriteLocalizedStrings_GetStringLength(lfnames, index, &length); + nameW = heap_alloc((length + 1) * sizeof(WCHAR)); + if (nameW) { + *nameW = 0; + IDWriteLocalizedStrings_GetString(lfnames, index, nameW, length + 1); + lstrcpynW(lfname, nameW, LF_FACESIZE); + heap_free(nameW); + } + }
IDWriteLocalizedStrings_Release(lfnames); } diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index db9949faac..f23bfcc63b 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -2515,6 +2515,7 @@ static void get_logfont_from_font(IDWriteFont *font, LOGFONTW *logfont) if (exists) { static const WCHAR enusW[] = {'e','n','-','u','s',0}; WCHAR localeW[LOCALE_NAME_MAX_LENGTH]; + WCHAR nameW[256]; UINT32 index;
/* Fallback to en-us if there's no string for user locale. */ @@ -2525,8 +2526,12 @@ static void get_logfont_from_font(IDWriteFont *font, LOGFONTW *logfont) if (!exists) IDWriteLocalizedStrings_FindLocaleName(names, enusW, &index, &exists);
- if (exists) - IDWriteLocalizedStrings_GetString(names, index, logfont->lfFaceName, ARRAY_SIZE(logfont->lfFaceName)); + if (exists) { + nameW[0] = 0; + hr = IDWriteLocalizedStrings_GetString(names, index, nameW, ARRAY_SIZE(nameW)); + ok(hr == S_OK, "Failed to get name string, hr %#x.\n", hr); + lstrcpynW(logfont->lfFaceName, nameW, ARRAY_SIZE(logfont->lfFaceName)); + } }
IDWriteLocalizedStrings_Release(names);