Commit b3cf1df4 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Use separate structure for set entry description.

parent 9250a3ab
...@@ -452,13 +452,18 @@ struct dwrite_fontresource ...@@ -452,13 +452,18 @@ struct dwrite_fontresource
IDWriteFactory7 *factory; IDWriteFactory7 *factory;
}; };
struct dwrite_fontset_entry struct dwrite_fontset_entry_desc
{ {
LONG refcount;
IDWriteFontFile *file; IDWriteFontFile *file;
DWRITE_FONT_FACE_TYPE face_type; DWRITE_FONT_FACE_TYPE face_type;
unsigned int face_index; unsigned int face_index;
unsigned int simulations; unsigned int simulations;
};
struct dwrite_fontset_entry
{
LONG refcount;
struct dwrite_fontset_entry_desc desc;
IDWriteLocalizedStrings *props[DWRITE_FONT_PROPERTY_ID_TYPOGRAPHIC_FACE_NAME + 1]; IDWriteLocalizedStrings *props[DWRITE_FONT_PROPERTY_ID_TYPOGRAPHIC_FACE_NAME + 1];
}; };
...@@ -7465,7 +7470,7 @@ static void release_fontset_entry(struct dwrite_fontset_entry *entry) ...@@ -7465,7 +7470,7 @@ static void release_fontset_entry(struct dwrite_fontset_entry *entry)
if (InterlockedDecrement(&entry->refcount) > 0) if (InterlockedDecrement(&entry->refcount) > 0)
return; return;
IDWriteFontFile_Release(entry->file); IDWriteFontFile_Release(entry->desc.file);
for (i = 0; i < ARRAY_SIZE(entry->props); ++i) for (i = 0; i < ARRAY_SIZE(entry->props); ++i)
{ {
if (entry->props[i] && entry->props[i] != MISSING_SET_PROP) if (entry->props[i] && entry->props[i] != MISSING_SET_PROP)
...@@ -7497,9 +7502,9 @@ static IDWriteLocalizedStrings * fontset_entry_get_property(struct dwrite_fontse ...@@ -7497,9 +7502,9 @@ static IDWriteLocalizedStrings * fontset_entry_get_property(struct dwrite_fontse
return value; return value;
} }
get_filestream_from_file(entry->file, &stream_desc.stream); get_filestream_from_file(entry->desc.file, &stream_desc.stream);
stream_desc.face_type = entry->face_type; stream_desc.face_type = entry->desc.face_type;
stream_desc.face_index = entry->face_index; stream_desc.face_index = entry->desc.face_index;
if (property == DWRITE_FONT_PROPERTY_ID_FULL_NAME) if (property == DWRITE_FONT_PROPERTY_ID_FULL_NAME)
opentype_get_font_info_strings(&stream_desc, DWRITE_INFORMATIONAL_STRING_FULL_NAME, &value); opentype_get_font_info_strings(&stream_desc, DWRITE_INFORMATIONAL_STRING_FULL_NAME, &value);
...@@ -7572,8 +7577,8 @@ static HRESULT WINAPI dwritefontset_GetFontFaceReference(IDWriteFontSet3 *iface, ...@@ -7572,8 +7577,8 @@ static HRESULT WINAPI dwritefontset_GetFontFaceReference(IDWriteFontSet3 *iface,
if (index >= set->count) if (index >= set->count)
return E_INVALIDARG; return E_INVALIDARG;
return IDWriteFactory7_CreateFontFaceReference_(set->factory, set->entries[index]->file, return IDWriteFactory7_CreateFontFaceReference_(set->factory, set->entries[index]->desc.file,
set->entries[index]->face_index, set->entries[index]->simulations, reference); set->entries[index]->desc.face_index, set->entries[index]->desc.simulations, reference);
} }
static HRESULT WINAPI dwritefontset_FindFontFaceReference(IDWriteFontSet3 *iface, static HRESULT WINAPI dwritefontset_FindFontFaceReference(IDWriteFontSet3 *iface,
...@@ -7820,8 +7825,8 @@ static HRESULT WINAPI dwritefontset1_CreateFontResource(IDWriteFontSet3 *iface, ...@@ -7820,8 +7825,8 @@ static HRESULT WINAPI dwritefontset1_CreateFontResource(IDWriteFontSet3 *iface,
if (index >= set->count) if (index >= set->count)
return E_INVALIDARG; return E_INVALIDARG;
return IDWriteFactory7_CreateFontResource(set->factory, set->entries[index]->file, return IDWriteFactory7_CreateFontResource(set->factory, set->entries[index]->desc.file,
set->entries[index]->face_index, resource); set->entries[index]->desc.face_index, resource);
} }
static HRESULT WINAPI dwritefontset1_CreateFontFace(IDWriteFontSet3 *iface, UINT32 index, IDWriteFontFace5 **fontface) static HRESULT WINAPI dwritefontset1_CreateFontFace(IDWriteFontSet3 *iface, UINT32 index, IDWriteFontFace5 **fontface)
...@@ -7909,11 +7914,11 @@ static HRESULT fontset_create_entry(IDWriteFontFile *file, DWRITE_FONT_FACE_TYPE ...@@ -7909,11 +7914,11 @@ static HRESULT fontset_create_entry(IDWriteFontFile *file, DWRITE_FONT_FACE_TYPE
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
entry->refcount = 1; entry->refcount = 1;
entry->file = file; entry->desc.file = file;
IDWriteFontFile_AddRef(entry->file); IDWriteFontFile_AddRef(entry->desc.file);
entry->face_type = face_type; entry->desc.face_type = face_type;
entry->face_index = face_index; entry->desc.face_index = face_index;
entry->simulations = simulations; entry->desc.simulations = simulations;
*ret = entry; *ret = entry;
...@@ -8034,8 +8039,7 @@ static ULONG WINAPI dwritefontsetbuilder_Release(IDWriteFontSetBuilder2 *iface) ...@@ -8034,8 +8039,7 @@ static ULONG WINAPI dwritefontsetbuilder_Release(IDWriteFontSetBuilder2 *iface)
return refcount; return refcount;
} }
static HRESULT fontset_builder_add_entry(struct dwrite_fontset_builder *builder, IDWriteFontFile *file, static HRESULT fontset_builder_add_entry(struct dwrite_fontset_builder *builder, const struct dwrite_fontset_entry_desc *desc)
DWRITE_FONT_FACE_TYPE face_type, unsigned int face_index, unsigned int simulations)
{ {
struct dwrite_fontset_entry *entry; struct dwrite_fontset_entry *entry;
HRESULT hr; HRESULT hr;
...@@ -8046,7 +8050,7 @@ static HRESULT fontset_builder_add_entry(struct dwrite_fontset_builder *builder, ...@@ -8046,7 +8050,7 @@ static HRESULT fontset_builder_add_entry(struct dwrite_fontset_builder *builder,
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
if (FAILED(hr = fontset_create_entry(file, face_type, face_index, simulations, &entry))) if (FAILED(hr = fontset_create_entry(desc->file, desc->face_type, desc->face_index, desc->simulations, &entry)))
return hr; return hr;
builder->entries[builder->count++] = entry; builder->entries[builder->count++] = entry;
...@@ -8056,13 +8060,14 @@ static HRESULT fontset_builder_add_entry(struct dwrite_fontset_builder *builder, ...@@ -8056,13 +8060,14 @@ static HRESULT fontset_builder_add_entry(struct dwrite_fontset_builder *builder,
static HRESULT fontset_builder_add_file(struct dwrite_fontset_builder *builder, IDWriteFontFile *file) static HRESULT fontset_builder_add_file(struct dwrite_fontset_builder *builder, IDWriteFontFile *file)
{ {
struct dwrite_fontset_entry_desc desc = { 0 };
DWRITE_FONT_FILE_TYPE filetype; DWRITE_FONT_FILE_TYPE filetype;
DWRITE_FONT_FACE_TYPE facetype;
unsigned int i, face_count; unsigned int i, face_count;
BOOL supported = FALSE; BOOL supported = FALSE;
HRESULT hr; HRESULT hr;
if (FAILED(hr = IDWriteFontFile_Analyze(file, &supported, &filetype, &facetype, &face_count))) desc.file = file;
if (FAILED(hr = IDWriteFontFile_Analyze(desc.file, &supported, &filetype, &desc.face_type, &face_count)))
return hr; return hr;
if (!supported) if (!supported)
...@@ -8070,7 +8075,8 @@ static HRESULT fontset_builder_add_file(struct dwrite_fontset_builder *builder, ...@@ -8070,7 +8075,8 @@ static HRESULT fontset_builder_add_file(struct dwrite_fontset_builder *builder,
for (i = 0; i < face_count; ++i) for (i = 0; i < face_count; ++i)
{ {
if (FAILED(hr = fontset_builder_add_entry(builder, file, facetype, i, DWRITE_FONT_SIMULATIONS_NONE))) desc.face_index = i;
if (FAILED(hr = fontset_builder_add_entry(builder, &desc)))
break; break;
} }
...@@ -8086,34 +8092,33 @@ static HRESULT WINAPI dwritefontsetbuilder_AddFontFaceReference_(IDWriteFontSetB ...@@ -8086,34 +8092,33 @@ static HRESULT WINAPI dwritefontsetbuilder_AddFontFaceReference_(IDWriteFontSetB
} }
static HRESULT WINAPI dwritefontsetbuilder_AddFontFaceReference(IDWriteFontSetBuilder2 *iface, static HRESULT WINAPI dwritefontsetbuilder_AddFontFaceReference(IDWriteFontSetBuilder2 *iface,
IDWriteFontFaceReference *ref) IDWriteFontFaceReference *reference)
{ {
struct dwrite_fontset_builder *builder = impl_from_IDWriteFontSetBuilder2(iface); struct dwrite_fontset_builder *builder = impl_from_IDWriteFontSetBuilder2(iface);
unsigned int face_count, face_index, simulations; struct dwrite_fontset_entry_desc desc = { 0 };
DWRITE_FONT_FILE_TYPE file_type; DWRITE_FONT_FILE_TYPE file_type;
DWRITE_FONT_FACE_TYPE face_type; unsigned int face_count;
IDWriteFontFile *file;
BOOL supported; BOOL supported;
HRESULT hr; HRESULT hr;
TRACE("%p, %p.\n", iface, ref); TRACE("%p, %p.\n", iface, reference);
if (FAILED(hr = IDWriteFontFaceReference_GetFontFile(ref, &file))) return hr; if (FAILED(hr = IDWriteFontFaceReference_GetFontFile(reference, &desc.file))) return hr;
if (FAILED(hr = IDWriteFontFile_Analyze(file, &supported, &file_type, &face_type, &face_count)))
goto done;
if (!supported) if (SUCCEEDED(hr = IDWriteFontFile_Analyze(desc.file, &supported, &file_type, &desc.face_type, &face_count)))
{ {
hr = DWRITE_E_FILEFORMAT; if (!supported)
goto done; hr = DWRITE_E_FILEFORMAT;
}
face_index = IDWriteFontFaceReference_GetFontFaceIndex(ref); if (SUCCEEDED(hr))
simulations = IDWriteFontFaceReference_GetSimulations(ref); {
hr = fontset_builder_add_entry(builder, file, face_type, face_index, simulations); desc.face_index = IDWriteFontFaceReference_GetFontFaceIndex(reference);
desc.simulations = IDWriteFontFaceReference_GetSimulations(reference);
hr = fontset_builder_add_entry(builder, &desc);
}
}
done: IDWriteFontFile_Release(desc.file);
IDWriteFontFile_Release(file);
return hr; return hr;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment