dwrite: Access font data directly at font level for GetInformationalStrings().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2d289681eb
commit
8d48f9d014
|
@ -324,7 +324,7 @@ extern const void* get_fontface_table(IDWriteFontFace5 *fontface, UINT32 tag,
|
|||
struct dwrite_fonttable *table) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,BOOL*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,UINT32*) DECLSPEC_HIDDEN;
|
||||
extern HRESULT opentype_try_get_font_table(struct file_stream_desc *stream_desc, UINT32 tag, const void **data,
|
||||
extern HRESULT opentype_try_get_font_table(const struct file_stream_desc *stream_desc, UINT32 tag, const void **data,
|
||||
void **context, UINT32 *size, BOOL *exists) DECLSPEC_HIDDEN;
|
||||
extern HRESULT opentype_cmap_get_unicode_ranges(const struct dwrite_fonttable *table, unsigned int max_count,
|
||||
DWRITE_UNICODE_RANGE *ranges, unsigned int *count) DECLSPEC_HIDDEN;
|
||||
|
@ -332,7 +332,8 @@ extern void opentype_get_font_properties(struct file_stream_desc*,struct dwrite_
|
|||
extern void opentype_get_font_metrics(struct file_stream_desc*,DWRITE_FONT_METRICS1*,DWRITE_CARET_METRICS*) DECLSPEC_HIDDEN;
|
||||
extern void opentype_get_font_typo_metrics(struct file_stream_desc *stream_desc, unsigned int *ascent,
|
||||
unsigned int *descent) DECLSPEC_HIDDEN;
|
||||
extern HRESULT opentype_get_font_info_strings(const void*,DWRITE_INFORMATIONAL_STRING_ID,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
|
||||
extern HRESULT opentype_get_font_info_strings(const struct file_stream_desc *stream_desc,
|
||||
DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
|
||||
extern HRESULT opentype_get_font_familyname(struct file_stream_desc*,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
|
||||
extern HRESULT opentype_get_font_facename(struct file_stream_desc*,WCHAR*,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
|
||||
extern HRESULT opentype_get_typographic_features(IDWriteFontFace*,UINT32,UINT32,UINT32,UINT32*,DWRITE_FONT_FEATURE_TAG*) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -1640,7 +1640,7 @@ static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont3 *iface,
|
|||
{
|
||||
struct dwrite_font *font = impl_from_IDWriteFont3(iface);
|
||||
struct dwrite_font_data *data = font->data;
|
||||
HRESULT hr;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
TRACE("%p, %d, %p, %p.\n", iface, stringid, strings, exists);
|
||||
|
||||
|
@ -1652,37 +1652,27 @@ static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont3 *iface,
|
|||
|
||||
if (!data->info_strings[stringid])
|
||||
{
|
||||
IDWriteFontFace5 *fontface;
|
||||
const void *table_data;
|
||||
BOOL table_exists;
|
||||
void *context;
|
||||
UINT32 size;
|
||||
struct file_stream_desc stream_desc;
|
||||
|
||||
hr = get_fontface_from_font(font, &fontface);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
table_exists = FALSE;
|
||||
hr = IDWriteFontFace5_TryGetFontTable(fontface, MS_NAME_TAG, &table_data, &size, &context, &table_exists);
|
||||
if (FAILED(hr) || !table_exists)
|
||||
WARN("no NAME table found.\n");
|
||||
|
||||
if (table_exists)
|
||||
if (SUCCEEDED(hr = get_filestream_from_file(data->file, &stream_desc.stream)))
|
||||
{
|
||||
hr = opentype_get_font_info_strings(table_data, stringid, &data->info_strings[stringid]);
|
||||
IDWriteFontFace5_ReleaseFontTable(fontface, context);
|
||||
if (FAILED(hr) || !data->info_strings[stringid])
|
||||
return hr;
|
||||
stream_desc.face_type = data->face_type;
|
||||
stream_desc.face_index = data->face_index;
|
||||
|
||||
hr = opentype_get_font_info_strings(&stream_desc, stringid, &data->info_strings[stringid]);
|
||||
|
||||
IDWriteFontFileStream_Release(stream_desc.stream);
|
||||
}
|
||||
IDWriteFontFace5_Release(fontface);
|
||||
}
|
||||
|
||||
hr = clone_localizedstrings(data->info_strings[stringid], strings);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
if (SUCCEEDED(hr) && data->info_strings[stringid])
|
||||
{
|
||||
hr = clone_localizedstrings(data->info_strings[stringid], strings);
|
||||
if (SUCCEEDED(hr))
|
||||
*exists = TRUE;
|
||||
}
|
||||
|
||||
*exists = TRUE;
|
||||
return S_OK;
|
||||
return hr;
|
||||
}
|
||||
|
||||
static DWRITE_FONT_SIMULATIONS WINAPI dwritefont_GetSimulations(IDWriteFont3 *iface)
|
||||
|
|
|
@ -1380,7 +1380,7 @@ HRESULT opentype_analyze_font(IDWriteFontFileStream *stream, BOOL *supported, DW
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT opentype_try_get_font_table(struct file_stream_desc *stream_desc, UINT32 tag, const void **table_data,
|
||||
HRESULT opentype_try_get_font_table(const struct file_stream_desc *stream_desc, UINT32 tag, const void **table_data,
|
||||
void **table_context, UINT32 *table_size, BOOL *found)
|
||||
{
|
||||
void *table_directory_context, *sfnt_context;
|
||||
|
@ -1448,7 +1448,7 @@ HRESULT opentype_try_get_font_table(struct file_stream_desc *stream_desc, UINT32
|
|||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT opentype_get_font_table(struct file_stream_desc *stream_desc, UINT32 tag,
|
||||
static HRESULT opentype_get_font_table(const struct file_stream_desc *stream_desc, UINT32 tag,
|
||||
struct dwrite_fonttable *table)
|
||||
{
|
||||
return opentype_try_get_font_table(stream_desc, tag, (const void **)&table->data, &table->context, &table->size, &table->exists);
|
||||
|
@ -2109,9 +2109,20 @@ static HRESULT opentype_get_font_strings_from_id(const void *table_data, enum OP
|
|||
}
|
||||
|
||||
/* Provides a conversion from DWRITE to OpenType name ids, input id should be valid, it's not checked. */
|
||||
HRESULT opentype_get_font_info_strings(const void *table_data, DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **strings)
|
||||
HRESULT opentype_get_font_info_strings(const struct file_stream_desc *stream_desc, DWRITE_INFORMATIONAL_STRING_ID id,
|
||||
IDWriteLocalizedStrings **strings)
|
||||
{
|
||||
return opentype_get_font_strings_from_id(table_data, dwriteid_to_opentypeid[id], strings);
|
||||
struct dwrite_fonttable name;
|
||||
HRESULT hr;
|
||||
|
||||
opentype_get_font_table(stream_desc, MS_NAME_TAG, &name);
|
||||
|
||||
hr = opentype_get_font_strings_from_id(name.data, dwriteid_to_opentypeid[id], strings);
|
||||
|
||||
if (name.context)
|
||||
IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, name.context);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/* FamilyName locating order is WWS Family Name -> Preferred Family Name -> Family Name. If font claims to
|
||||
|
|
Loading…
Reference in New Issue