dwrite: Look for English name strings in mac platform records.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0d07d1ec61
commit
2d8f32be7d
|
@ -298,6 +298,7 @@ extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const W
|
||||||
extern HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
|
extern HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
|
||||||
extern void set_en_localizedstring(IDWriteLocalizedStrings*,const WCHAR*) DECLSPEC_HIDDEN;
|
extern void set_en_localizedstring(IDWriteLocalizedStrings*,const WCHAR*) DECLSPEC_HIDDEN;
|
||||||
extern void sort_localizedstrings(IDWriteLocalizedStrings*) DECLSPEC_HIDDEN;
|
extern void sort_localizedstrings(IDWriteLocalizedStrings*) DECLSPEC_HIDDEN;
|
||||||
|
extern unsigned int get_localizedstrings_count(IDWriteLocalizedStrings *strings) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT get_system_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection1 **collection) DECLSPEC_HIDDEN;
|
extern HRESULT get_system_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection1 **collection) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN;
|
extern HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **collection) DECLSPEC_HIDDEN;
|
||||||
extern IDWriteTextAnalyzer2 *get_text_analyzer(void) DECLSPEC_HIDDEN;
|
extern IDWriteTextAnalyzer2 *get_text_analyzer(void) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -323,11 +323,9 @@ static ULONG WINAPI localizedstrings_Release(IDWriteLocalizedStrings *iface)
|
||||||
|
|
||||||
static UINT32 WINAPI localizedstrings_GetCount(IDWriteLocalizedStrings *iface)
|
static UINT32 WINAPI localizedstrings_GetCount(IDWriteLocalizedStrings *iface)
|
||||||
{
|
{
|
||||||
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
||||||
|
|
||||||
TRACE("%p.\n", iface);
|
TRACE("%p.\n", iface);
|
||||||
|
|
||||||
return strings->count;
|
return get_localizedstrings_count(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI localizedstrings_FindLocaleName(IDWriteLocalizedStrings *iface,
|
static HRESULT WINAPI localizedstrings_FindLocaleName(IDWriteLocalizedStrings *iface,
|
||||||
|
@ -559,6 +557,12 @@ void sort_localizedstrings(IDWriteLocalizedStrings *iface)
|
||||||
qsort(strings->data, strings->count, sizeof(*strings->data), localizedstrings_sorting_compare);
|
qsort(strings->data, strings->count, sizeof(*strings->data), localizedstrings_sorting_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int get_localizedstrings_count(IDWriteLocalizedStrings *iface)
|
||||||
|
{
|
||||||
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
||||||
|
return strings->count;
|
||||||
|
}
|
||||||
|
|
||||||
struct collectionloader
|
struct collectionloader
|
||||||
{
|
{
|
||||||
struct list entry;
|
struct list entry;
|
||||||
|
|
|
@ -2288,9 +2288,21 @@ static void get_name_record_locale(enum OPENTYPE_PLATFORM_ID platform, USHORT la
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL opentype_is_english_namerecord(const struct dwrite_fonttable *table, unsigned int idx)
|
||||||
|
{
|
||||||
|
const struct name_header *header = (const struct name_header *)table->data;
|
||||||
|
const struct name_record *record;
|
||||||
|
|
||||||
|
record = &header->records[idx];
|
||||||
|
|
||||||
|
return GET_BE_WORD(record->platformID) == OPENTYPE_PLATFORM_MAC &&
|
||||||
|
GET_BE_WORD(record->languageID) == TT_NAME_MAC_LANGID_ENGLISH;
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, unsigned int idx,
|
static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, unsigned int idx,
|
||||||
IDWriteLocalizedStrings *strings)
|
IDWriteLocalizedStrings *strings)
|
||||||
{
|
{
|
||||||
|
static const WCHAR enusW[] = {'e','n','-','U','S',0};
|
||||||
USHORT lang_id, length, offset, encoding, platform;
|
USHORT lang_id, length, offset, encoding, platform;
|
||||||
const struct name_header *header = (const struct name_header *)table->data;
|
const struct name_header *header = (const struct name_header *)table->data;
|
||||||
const struct name_record *record;
|
const struct name_record *record;
|
||||||
|
@ -2338,7 +2350,8 @@ static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, uns
|
||||||
TRACE("string %s for locale %s found\n", debugstr_w(name_string), debugstr_w(locale));
|
TRACE("string %s for locale %s found\n", debugstr_w(name_string), debugstr_w(locale));
|
||||||
add_localizedstring(strings, locale, name_string);
|
add_localizedstring(strings, locale, name_string);
|
||||||
heap_free(name_string);
|
heap_free(name_string);
|
||||||
ret = TRUE;
|
|
||||||
|
ret = !lstrcmpW(locale, enusW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
FIXME("handle NAME format 1\n");
|
FIXME("handle NAME format 1\n");
|
||||||
|
@ -2349,10 +2362,10 @@ static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, uns
|
||||||
static HRESULT opentype_get_font_strings_from_id(const struct dwrite_fonttable *table, enum OPENTYPE_STRING_ID id,
|
static HRESULT opentype_get_font_strings_from_id(const struct dwrite_fonttable *table, enum OPENTYPE_STRING_ID id,
|
||||||
IDWriteLocalizedStrings **strings)
|
IDWriteLocalizedStrings **strings)
|
||||||
{
|
{
|
||||||
int i, count, candidate_mac, candidate_unicode;
|
int i, count, candidate_mac, candidate_mac_en, candidate_unicode;
|
||||||
const struct name_record *records;
|
const struct name_record *records;
|
||||||
|
BOOL has_english;
|
||||||
WORD format;
|
WORD format;
|
||||||
BOOL exists;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if (!table->data)
|
if (!table->data)
|
||||||
|
@ -2374,8 +2387,8 @@ static HRESULT opentype_get_font_strings_from_id(const struct dwrite_fonttable *
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
exists = FALSE;
|
has_english = FALSE;
|
||||||
candidate_unicode = candidate_mac = -1;
|
candidate_unicode = candidate_mac = candidate_mac_en = -1;
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
|
@ -2398,10 +2411,11 @@ static HRESULT opentype_get_font_strings_from_id(const struct dwrite_fonttable *
|
||||||
case OPENTYPE_PLATFORM_MAC:
|
case OPENTYPE_PLATFORM_MAC:
|
||||||
if (candidate_mac == -1)
|
if (candidate_mac == -1)
|
||||||
candidate_mac = i;
|
candidate_mac = i;
|
||||||
|
if (candidate_mac_en == -1 && opentype_is_english_namerecord(table, i))
|
||||||
|
candidate_mac_en = i;
|
||||||
break;
|
break;
|
||||||
case OPENTYPE_PLATFORM_WIN:
|
case OPENTYPE_PLATFORM_WIN:
|
||||||
if (opentype_decode_namerecord(table, i, *strings))
|
has_english |= opentype_decode_namerecord(table, i, *strings);
|
||||||
exists = TRUE;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("platform %i not supported\n", platform);
|
FIXME("platform %i not supported\n", platform);
|
||||||
|
@ -2409,24 +2423,23 @@ static HRESULT opentype_get_font_strings_from_id(const struct dwrite_fonttable *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists)
|
if (!get_localizedstrings_count(*strings) && candidate_mac != -1)
|
||||||
{
|
has_english |= opentype_decode_namerecord(table, candidate_mac, *strings);
|
||||||
if (candidate_mac != -1)
|
if (!get_localizedstrings_count(*strings) && candidate_unicode != -1)
|
||||||
exists = opentype_decode_namerecord(table, candidate_mac, *strings);
|
has_english |= opentype_decode_namerecord(table, candidate_unicode, *strings);
|
||||||
if (!exists && candidate_unicode != -1)
|
if (!has_english && candidate_mac_en != -1)
|
||||||
exists = opentype_decode_namerecord(table, candidate_unicode, *strings);
|
opentype_decode_namerecord(table, candidate_mac_en, *strings);
|
||||||
|
|
||||||
if (!exists)
|
if (!get_localizedstrings_count(*strings))
|
||||||
{
|
{
|
||||||
IDWriteLocalizedStrings_Release(*strings);
|
IDWriteLocalizedStrings_Release(*strings);
|
||||||
*strings = NULL;
|
*strings = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (*strings)
|
if (*strings)
|
||||||
sort_localizedstrings(*strings);
|
sort_localizedstrings(*strings);
|
||||||
|
|
||||||
return exists ? S_OK : E_FAIL;
|
return *strings ? S_OK : E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WCHAR *meta_get_lng_name(WCHAR *str, WCHAR **ctx)
|
static WCHAR *meta_get_lng_name(WCHAR *str, WCHAR **ctx)
|
||||||
|
|
Loading…
Reference in New Issue