gdi32: Fixed family and face name on non English locale.

This commit is contained in:
Qian Hong 2012-09-07 18:41:02 +08:00 committed by Alexandre Julliard
parent 733aca30f4
commit 245308597f
2 changed files with 24 additions and 17 deletions

View File

@ -1552,7 +1552,7 @@ static void get_family_names( FT_Face ft_face, WCHAR **name, WCHAR **english, BO
*english = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, TT_MS_LANGID_ENGLISH_UNITED_STATES ); *english = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, TT_MS_LANGID_ENGLISH_UNITED_STATES );
if (!*english) *english = towstr( CP_ACP, ft_face->family_name ); if (!*english) *english = towstr( CP_ACP, ft_face->family_name );
*name = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, GetUserDefaultLCID() ); *name = get_face_name( ft_face, TT_NAME_ID_FONT_FAMILY, GetSystemDefaultLCID() );
if (!*name) if (!*name)
{ {
*name = *english; *name = *english;
@ -1715,6 +1715,8 @@ static Face *create_face( FT_Face ft_face, FT_Long face_index, const char *file,
My_FT_Bitmap_Size *size = (My_FT_Bitmap_Size *)ft_face->available_sizes; My_FT_Bitmap_Size *size = (My_FT_Bitmap_Size *)ft_face->available_sizes;
face->StyleName = towstr( CP_ACP, ft_face->style_name ); face->StyleName = towstr( CP_ACP, ft_face->style_name );
face->FullName = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, GetSystemDefaultLangID() );
if (!face->FullName)
face->FullName = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, TT_MS_LANGID_ENGLISH_UNITED_STATES ); face->FullName = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, TT_MS_LANGID_ENGLISH_UNITED_STATES );
if (file) if (file)
{ {
@ -6553,6 +6555,8 @@ static BOOL get_outline_text_metrics(GdiFont *font)
MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1, MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1,
style_nameW, lensty/sizeof(WCHAR)); style_nameW, lensty/sizeof(WCHAR));
face_nameW = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, GetSystemDefaultLangID() );
if (!face_nameW)
face_nameW = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, TT_MS_LANGID_ENGLISH_UNITED_STATES ); face_nameW = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, TT_MS_LANGID_ENGLISH_UNITED_STATES );
if (!face_nameW) if (!face_nameW)
{ {

View File

@ -2784,7 +2784,7 @@ end:
#define TT_NAME_ID_UNIQUE_ID 3 #define TT_NAME_ID_UNIQUE_ID 3
#define TT_NAME_ID_FULL_NAME 4 #define TT_NAME_ID_FULL_NAME 4
static BOOL get_ttf_nametable_entry(HDC hdc, WORD name_id, WCHAR *out_buf, SIZE_T out_size) static BOOL get_ttf_nametable_entry(HDC hdc, WORD name_id, WCHAR *out_buf, SIZE_T out_size, LCID language_id)
{ {
struct sfnt_name_header struct sfnt_name_header
{ {
@ -2841,7 +2841,7 @@ static BOOL get_ttf_nametable_entry(HDC hdc, WORD name_id, WCHAR *out_buf, SIZE_
{ {
if (GET_BE_WORD(entry[i].platform_id) != TT_PLATFORM_MICROSOFT || if (GET_BE_WORD(entry[i].platform_id) != TT_PLATFORM_MICROSOFT ||
GET_BE_WORD(entry[i].encoding_id) != TT_MS_ID_UNICODE_CS || GET_BE_WORD(entry[i].encoding_id) != TT_MS_ID_UNICODE_CS ||
GET_BE_WORD(entry[i].language_id) != TT_MS_LANGID_ENGLISH_UNITED_STATES || GET_BE_WORD(entry[i].language_id) != language_id ||
GET_BE_WORD(entry[i].name_id) != name_id) GET_BE_WORD(entry[i].name_id) != name_id)
{ {
continue; continue;
@ -4035,7 +4035,7 @@ static void test_fullname(void)
of = SelectObject(hdc, hfont); of = SelectObject(hdc, hfont);
bufW[0] = 0; bufW[0] = 0;
bufA[0] = 0; bufA[0] = 0;
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FULL_NAME, bufW, sizeof(bufW)); ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FULL_NAME, bufW, sizeof(bufW), TT_MS_LANGID_ENGLISH_UNITED_STATES);
ok(ret, "face full name could not be read\n"); ok(ret, "face full name could not be read\n");
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, sizeof(bufW), NULL, FALSE); WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, sizeof(bufW), NULL, FALSE);
ok(!lstrcmpA(bufA, TestName[i]), "font full names don't match: %s != %s\n", TestName[i], bufA); ok(!lstrcmpA(bufA, TestName[i]), "font full names don't match: %s != %s\n", TestName[i], bufA);
@ -4057,13 +4057,6 @@ static void test_fullname2_helper(const char *Family)
int i; int i;
DWORD otm_size, ret, buf_size; DWORD otm_size, ret, buf_size;
OUTLINETEXTMETRICA *otm; OUTLINETEXTMETRICA *otm;
LCID lcid = GetSystemDefaultLangID();
if (lcid != TT_MS_LANGID_ENGLISH_UNITED_STATES)
{
skip("Skip test: LCID = %d\n", lcid);
return;
}
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
ok(hdc != NULL, "CreateCompatibleDC failed\n"); ok(hdc != NULL, "CreateCompatibleDC failed\n");
@ -4111,7 +4104,12 @@ static void test_fullname2_helper(const char *Family)
bufW[0] = 0; bufW[0] = 0;
bufA[0] = 0; bufA[0] = 0;
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_FAMILY, bufW, buf_size); ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_FAMILY, bufW, buf_size, GetSystemDefaultLangID());
if (!ret)
{
trace("no localized name found.\n");
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_FAMILY, bufW, buf_size, TT_MS_LANGID_ENGLISH_UNITED_STATES);
}
ok(ret, "FAMILY (family name) could not be read\n"); ok(ret, "FAMILY (family name) could not be read\n");
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE); WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
ok(!lstrcmpA(FamilyName, bufA), "font family names don't match: returned %s, expect %s\n", FamilyName, bufA); ok(!lstrcmpA(FamilyName, bufA), "font family names don't match: returned %s, expect %s\n", FamilyName, bufA);
@ -4120,7 +4118,12 @@ static void test_fullname2_helper(const char *Family)
bufW[0] = 0; bufW[0] = 0;
bufA[0] = 0; bufA[0] = 0;
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FULL_NAME, bufW, buf_size); ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FULL_NAME, bufW, buf_size, GetSystemDefaultLangID());
if (!ret)
{
trace("no localized name found.\n");
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FULL_NAME, bufW, buf_size, TT_MS_LANGID_ENGLISH_UNITED_STATES);
}
ok(ret, "FULL_NAME (face name) could not be read\n"); ok(ret, "FULL_NAME (face name) could not be read\n");
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE); WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
ok(!lstrcmpA(FaceName, bufA), "font face names don't match: returned %s, expect %s\n", FaceName, bufA); ok(!lstrcmpA(FaceName, bufA), "font face names don't match: returned %s, expect %s\n", FaceName, bufA);
@ -4129,7 +4132,7 @@ static void test_fullname2_helper(const char *Family)
bufW[0] = 0; bufW[0] = 0;
bufA[0] = 0; bufA[0] = 0;
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_SUBFAMILY, bufW, buf_size); ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_FONT_SUBFAMILY, bufW, buf_size, TT_MS_LANGID_ENGLISH_UNITED_STATES);
ok(ret, "SUBFAMILY (style name) could not be read\n"); ok(ret, "SUBFAMILY (style name) could not be read\n");
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE); WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
ok(!lstrcmpA(StyleName, bufA), "style names don't match: returned %s, expect %s\n", FaceName, bufA); ok(!lstrcmpA(StyleName, bufA), "style names don't match: returned %s, expect %s\n", FaceName, bufA);
@ -4138,7 +4141,7 @@ static void test_fullname2_helper(const char *Family)
bufW[0] = 0; bufW[0] = 0;
bufA[0] = 0; bufA[0] = 0;
ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_UNIQUE_ID, bufW, buf_size); ret = get_ttf_nametable_entry(hdc, TT_NAME_ID_UNIQUE_ID, bufW, buf_size, TT_MS_LANGID_ENGLISH_UNITED_STATES);
ok(ret, "UNIQUE_ID (full name) could not be read\n"); ok(ret, "UNIQUE_ID (full name) could not be read\n");
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE); WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpFullName; otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpFullName;