dwrite: Accept platform 0 name records if there's nothing, else.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b274ce44b0
commit
ec3c7d9d3a
@ -1281,68 +1281,21 @@ static void get_name_record_locale(enum OPENTYPE_PLATFORM_ID platform, USHORT la
|
|||||||
strcpyW(locale, enusW);
|
strcpyW(locale, enusW);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case OPENTYPE_PLATFORM_UNICODE:
|
||||||
|
strcpyW(locale, enusW);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
FIXME("unknown platform %d\n", platform);
|
FIXME("unknown platform %d\n", platform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT opentype_get_font_strings_from_id(const void *table_data, enum OPENTYPE_STRING_ID id, IDWriteLocalizedStrings **strings)
|
static BOOL opentype_decode_namerecord(const TT_NAME_V0 *header, BYTE *storage_area, USHORT recid, IDWriteLocalizedStrings *strings)
|
||||||
{
|
{
|
||||||
const TT_NAME_V0 *header;
|
const TT_NameRecord *record = &header->nameRecord[recid];
|
||||||
BYTE *storage_area = 0;
|
|
||||||
USHORT count = 0;
|
|
||||||
WORD format;
|
|
||||||
BOOL exists;
|
|
||||||
HRESULT hr;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!table_data)
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
hr = create_localizedstrings(strings);
|
|
||||||
if (FAILED(hr)) return hr;
|
|
||||||
|
|
||||||
header = table_data;
|
|
||||||
format = GET_BE_WORD(header->format);
|
|
||||||
|
|
||||||
switch (format) {
|
|
||||||
case 0:
|
|
||||||
case 1:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
FIXME("unsupported NAME format %d\n", format);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
storage_area = (LPBYTE)table_data + GET_BE_WORD(header->stringOffset);
|
|
||||||
count = GET_BE_WORD(header->count);
|
|
||||||
|
|
||||||
exists = FALSE;
|
|
||||||
for (i = 0; i < count; i++) {
|
|
||||||
const TT_NameRecord *record = &header->nameRecord[i];
|
|
||||||
USHORT lang_id, length, offset, encoding, platform;
|
USHORT lang_id, length, offset, encoding, platform;
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
if (GET_BE_WORD(record->nameID) != id)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
exists = TRUE;
|
|
||||||
|
|
||||||
/* Right now only accept unicode and windows encoded fonts */
|
|
||||||
platform = GET_BE_WORD(record->platformID);
|
platform = GET_BE_WORD(record->platformID);
|
||||||
if (platform != OPENTYPE_PLATFORM_UNICODE &&
|
|
||||||
platform != OPENTYPE_PLATFORM_MAC &&
|
|
||||||
platform != OPENTYPE_PLATFORM_WIN)
|
|
||||||
{
|
|
||||||
FIXME("platform %i not supported\n", platform);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip such entries for now, as it's not clear which locale is implied when
|
|
||||||
unicode platform is used. Also fonts tend to duplicate those strings as
|
|
||||||
WIN platform entries. */
|
|
||||||
if (platform == OPENTYPE_PLATFORM_UNICODE)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
lang_id = GET_BE_WORD(record->languageID);
|
lang_id = GET_BE_WORD(record->languageID);
|
||||||
length = GET_BE_WORD(record->length);
|
length = GET_BE_WORD(record->length);
|
||||||
offset = GET_BE_WORD(record->offset);
|
offset = GET_BE_WORD(record->offset);
|
||||||
@ -1372,19 +1325,85 @@ static HRESULT opentype_get_font_strings_from_id(const void *table_data, enum OP
|
|||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
FIXME("handle NAME format 1\n");
|
FIXME("handle NAME format 1\n");
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT opentype_get_font_strings_from_id(const void *table_data, enum OPENTYPE_STRING_ID id, IDWriteLocalizedStrings **strings)
|
||||||
|
{
|
||||||
|
const TT_NAME_V0 *header;
|
||||||
|
BYTE *storage_area = 0;
|
||||||
|
USHORT count = 0;
|
||||||
|
int i, candidate;
|
||||||
|
WORD format;
|
||||||
|
BOOL exists;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
if (!table_data)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
hr = create_localizedstrings(strings);
|
||||||
|
if (FAILED(hr)) return hr;
|
||||||
|
|
||||||
|
header = table_data;
|
||||||
|
format = GET_BE_WORD(header->format);
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FIXME("unsupported NAME format %d\n", format);
|
||||||
|
}
|
||||||
|
|
||||||
|
storage_area = (LPBYTE)table_data + GET_BE_WORD(header->stringOffset);
|
||||||
|
count = GET_BE_WORD(header->count);
|
||||||
|
|
||||||
|
exists = FALSE;
|
||||||
|
candidate = -1;
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
const TT_NameRecord *record = &header->nameRecord[i];
|
||||||
|
USHORT platform;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
FIXME("platform %i not supported\n", platform);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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 (!(exists = opentype_decode_namerecord(header, storage_area, i, *strings)))
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
|
if (candidate != -1)
|
||||||
|
exists = opentype_decode_namerecord(header, storage_area, candidate, *strings);
|
||||||
|
else {
|
||||||
IDWriteLocalizedStrings_Release(*strings);
|
IDWriteLocalizedStrings_Release(*strings);
|
||||||
*strings = NULL;
|
*strings = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return exists ? S_OK : E_FAIL;
|
return exists ? S_OK : E_FAIL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user