dwrite: Store locale name in lower case for text format.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-01-08 12:55:37 +03:00 committed by Alexandre Julliard
parent f8a228d261
commit b1094bc7d7
2 changed files with 35 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/*
* Text format and layout
*
* Copyright 2012, 2014-2015 Nikolay Sivov for CodeWeavers
* Copyright 2012, 2014-2016 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -3923,7 +3923,11 @@ static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, I
layout->format.locale = heap_strdupW(textformat->format.locale);
layout->format.family_name = heap_strdupW(textformat->format.family_name);
if (!layout->format.locale || !layout->format.family_name)
{
heap_free(layout->format.locale);
heap_free(layout->format.family_name);
return E_OUTOFMEMORY;
}
if (layout->format.trimmingsign)
IDWriteInlineObject_AddRef(layout->format.trimmingsign);
@ -4662,6 +4666,8 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle
This->format.family_len = strlenW(family_name);
This->format.locale = heap_strdupW(locale);
This->format.locale_len = strlenW(locale);
/* force locale name to lower case, layout will inherit this modified value */
strlwrW(This->format.locale);
This->format.weight = weight;
This->format.style = style;
This->format.fontsize = size;

View File

@ -1999,7 +1999,7 @@ static void test_SetLocaleName(void)
static const WCHAR eNuSW[] = {'e','N','-','u','S',0};
static const WCHAR strW[] = {'a','b','c','d',0};
WCHAR buffW[LOCALE_NAME_MAX_LENGTH+sizeof(strW)/sizeof(WCHAR)];
IDWriteTextFormat *format;
IDWriteTextFormat *format, *format2;
IDWriteTextLayout *layout;
DWRITE_TEXT_RANGE range;
IDWriteFactory *factory;
@ -2007,6 +2007,33 @@ static void test_SetLocaleName(void)
factory = create_factory();
/* create format with mixed case locale name, get it back */
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, eNuSW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_GetLocaleName(format, buffW, sizeof(buffW)/sizeof(buffW[0]));
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(!lstrcmpW(buffW, enusW), "got %s\n", wine_dbgstr_w(buffW));
hr = IDWriteFactory_CreateTextLayout(factory, strW, 4, format, 1000.0, 1000.0, &layout);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextLayout_QueryInterface(layout, &IID_IDWriteTextFormat, (void**)&format2);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_GetLocaleName(format2, buffW, sizeof(buffW)/sizeof(buffW[0]));
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(!lstrcmpW(buffW, enusW), "got %s\n", wine_dbgstr_w(buffW));
hr = IDWriteTextLayout_GetLocaleName(layout, 0, buffW, sizeof(buffW)/sizeof(buffW[0]), NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(!lstrcmpW(buffW, enusW), "got %s\n", wine_dbgstr_w(buffW));
IDWriteTextFormat_Release(format2);
IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format);
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr);