[PATCH 1/2] dwrite: Prefer Windows platform names regardless of record order.
Nikolay Sivov
nsivov at codeweavers.com
Thu Sep 19 09:41:01 CDT 2019
From: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/dwrite/opentype.c | 57 +++++++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 26 deletions(-)
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index e8efa1d196..67a1a20427 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -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 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;
+ /* 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;
}
-
- 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);
+ else
+ {
IDWriteLocalizedStrings_Release(*strings);
*strings = NULL;
}
--
2.23.0
More information about the wine-devel
mailing list