dwrite: Prefer Windows platform names regardless of record order.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d44d83b684
commit
ea07bc4190
|
@ -1935,10 +1935,9 @@ static BOOL opentype_decode_namerecord(const TT_NAME_V0 *header, BYTE *storage_a
|
|||
|
||||
static HRESULT opentype_get_font_strings_from_id(const void *table_data, enum OPENTYPE_STRING_ID id, IDWriteLocalizedStrings **strings)
|
||||
{
|
||||
int i, count, candidate_mac, candidate_unicode;
|
||||
const TT_NAME_V0 *header;
|
||||
BYTE *storage_area = 0;
|
||||
USHORT count = 0;
|
||||
int i, candidate;
|
||||
WORD format;
|
||||
BOOL exists;
|
||||
HRESULT hr;
|
||||
|
@ -1964,7 +1963,7 @@ static HRESULT opentype_get_font_strings_from_id(const void *table_data, enum OP
|
|||
count = GET_BE_WORD(header->count);
|
||||
|
||||
exists = FALSE;
|
||||
candidate = -1;
|
||||
candidate_unicode = candidate_mac = -1;
|
||||
for (i = 0; i < count; i++) {
|
||||
const TT_NameRecord *record = &header->nameRecord[i];
|
||||
USHORT platform;
|
||||
|
@ -1972,34 +1971,40 @@ static HRESULT opentype_get_font_strings_from_id(const void *table_data, enum OP
|
|||
if (GET_BE_WORD(record->nameID) != id)
|
||||
continue;
|
||||
|
||||
/* Right now only accept unicode and windows encoded fonts */
|
||||
platform = GET_BE_WORD(record->platformID);
|
||||
if (platform != OPENTYPE_PLATFORM_UNICODE &&
|
||||
platform != OPENTYPE_PLATFORM_MAC &&
|
||||
platform != OPENTYPE_PLATFORM_WIN)
|
||||
switch (platform)
|
||||
{
|
||||
FIXME("platform %i not supported\n", platform);
|
||||
continue;
|
||||
/* Skip Unicode or Mac entries for now, fonts tend to duplicate those
|
||||
strings as WIN platform entries. If font does not have WIN entry for
|
||||
this id, we will use Mac or Unicode platform entry while assuming
|
||||
en-US locale. */
|
||||
case OPENTYPE_PLATFORM_UNICODE:
|
||||
if (candidate_unicode == -1)
|
||||
candidate_unicode = i;
|
||||
break;
|
||||
case OPENTYPE_PLATFORM_MAC:
|
||||
if (candidate_mac == -1)
|
||||
candidate_mac = i;
|
||||
break;
|
||||
case OPENTYPE_PLATFORM_WIN:
|
||||
if (opentype_decode_namerecord(header, storage_area, i, *strings))
|
||||
exists = TRUE;
|
||||
break;
|
||||
default:
|
||||
FIXME("platform %i not supported\n", platform);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Skip such entries for now, fonts tend to duplicate those strings as
|
||||
WIN platform entries. If font does not have WIN or MAC entry for this id, we will
|
||||
use this Unicode platform entry while assuming en-US locale. */
|
||||
if (platform == OPENTYPE_PLATFORM_UNICODE) {
|
||||
candidate = i;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!opentype_decode_namerecord(header, storage_area, i, *strings))
|
||||
continue;
|
||||
|
||||
exists = TRUE;
|
||||
}
|
||||
|
||||
if (!exists) {
|
||||
if (candidate != -1)
|
||||
exists = opentype_decode_namerecord(header, storage_area, candidate, *strings);
|
||||
else {
|
||||
if (!exists)
|
||||
{
|
||||
if (candidate_mac != -1)
|
||||
exists = opentype_decode_namerecord(header, storage_area, candidate_mac, *strings);
|
||||
if (!exists && candidate_unicode != -1)
|
||||
exists = opentype_decode_namerecord(header, storage_area, candidate_unicode, *strings);
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
IDWriteLocalizedStrings_Release(*strings);
|
||||
*strings = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue