Commit e5966d74 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Properly truncate face name to LOGFONT size.

parent 63bdcf97
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment