dwrite: Properly truncate face name to LOGFONT size.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
63bdcf97a7
commit
e5966d7475
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue