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

dwrite: Reuse streams when initializing font data and creating faces.

parent ab318438
...@@ -151,6 +151,7 @@ struct fontface_desc ...@@ -151,6 +151,7 @@ struct fontface_desc
IDWriteFactory5 *factory; IDWriteFactory5 *factory;
DWRITE_FONT_FACE_TYPE face_type; DWRITE_FONT_FACE_TYPE face_type;
IDWriteFontFile * const *files; IDWriteFontFile * const *files;
IDWriteFontFileStream *stream;
UINT32 files_number; UINT32 files_number;
UINT32 index; UINT32 index;
DWRITE_FONT_SIMULATIONS simulations; DWRITE_FONT_SIMULATIONS simulations;
...@@ -228,7 +229,7 @@ struct file_stream_desc { ...@@ -228,7 +229,7 @@ struct file_stream_desc {
UINT32 face_index; UINT32 face_index;
}; };
extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,UINT32*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,BOOL*) DECLSPEC_HIDDEN; extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,BOOL*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,UINT32*) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_font_table(struct file_stream_desc*,UINT32,const void**,void**,UINT32*,BOOL*) DECLSPEC_HIDDEN; extern HRESULT opentype_get_font_table(struct file_stream_desc*,UINT32,const void**,void**,UINT32*,BOOL*) DECLSPEC_HIDDEN;
extern HRESULT opentype_cmap_get_unicode_ranges(void*,UINT32,DWRITE_UNICODE_RANGE*,UINT32*) DECLSPEC_HIDDEN; extern HRESULT opentype_cmap_get_unicode_ranges(void*,UINT32,DWRITE_UNICODE_RANGE*,UINT32*) DECLSPEC_HIDDEN;
extern void opentype_get_font_properties(struct file_stream_desc*,struct dwrite_font_props*) DECLSPEC_HIDDEN; extern void opentype_get_font_properties(struct file_stream_desc*,struct dwrite_font_props*) DECLSPEC_HIDDEN;
......
...@@ -943,10 +943,11 @@ static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory5 *iface, DWRIT ...@@ -943,10 +943,11 @@ static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory5 *iface, DWRIT
struct dwritefactory *This = impl_from_IDWriteFactory5(iface); struct dwritefactory *This = impl_from_IDWriteFactory5(iface);
DWRITE_FONT_FILE_TYPE file_type; DWRITE_FONT_FILE_TYPE file_type;
DWRITE_FONT_FACE_TYPE face_type; DWRITE_FONT_FACE_TYPE face_type;
IDWriteFontFileStream *stream;
struct fontface_desc desc; struct fontface_desc desc;
struct list *fontfaces; struct list *fontfaces;
BOOL is_supported; BOOL is_supported;
UINT32 count; UINT32 face_count;
HRESULT hr; HRESULT hr;
TRACE("(%p)->(%d %u %p %u 0x%x %p)\n", This, req_facetype, files_number, font_files, index, TRACE("(%p)->(%d %u %p %u 0x%x %p)\n", This, req_facetype, files_number, font_files, index,
...@@ -963,32 +964,44 @@ static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory5 *iface, DWRIT ...@@ -963,32 +964,44 @@ static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory5 *iface, DWRIT
if (!is_simulation_valid(simulations)) if (!is_simulation_valid(simulations))
return E_INVALIDARG; return E_INVALIDARG;
if (FAILED(hr = get_filestream_from_file(*font_files, &stream)))
return hr;
/* check actual file/face type */ /* check actual file/face type */
is_supported = FALSE; is_supported = FALSE;
face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN; face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN;
hr = IDWriteFontFile_Analyze(*font_files, &is_supported, &file_type, &face_type, &count); hr = opentype_analyze_font(stream, &is_supported, &file_type, &face_type, &face_count);
if (FAILED(hr)) if (FAILED(hr))
return hr; goto failed;
if (!is_supported) if (!is_supported) {
return E_FAIL; hr = E_FAIL;
goto failed;
}
if (face_type != req_facetype) if (face_type != req_facetype) {
return DWRITE_E_FILEFORMAT; hr = DWRITE_E_FILEFORMAT;
goto failed;
}
hr = factory_get_cached_fontface(iface, font_files, index, simulations, &fontfaces, hr = factory_get_cached_fontface(iface, font_files, index, simulations, &fontfaces,
&IID_IDWriteFontFace, (void **)fontface); &IID_IDWriteFontFace, (void **)fontface);
if (hr != S_FALSE) if (hr != S_FALSE)
return hr; goto failed;
desc.factory = iface; desc.factory = iface;
desc.face_type = req_facetype; desc.face_type = req_facetype;
desc.files = font_files; desc.files = font_files;
desc.stream = stream;
desc.files_number = files_number; desc.files_number = files_number;
desc.index = index; desc.index = index;
desc.simulations = simulations; desc.simulations = simulations;
desc.font_data = NULL; desc.font_data = NULL;
return create_fontface(&desc, fontfaces, (IDWriteFontFace4 **)fontface); hr = create_fontface(&desc, fontfaces, (IDWriteFontFace4 **)fontface);
failed:
IDWriteFontFileStream_Release(stream);
return hr;
} }
static HRESULT WINAPI dwritefactory_CreateRenderingParams(IDWriteFactory5 *iface, IDWriteRenderingParams **params) static HRESULT WINAPI dwritefactory_CreateRenderingParams(IDWriteFactory5 *iface, IDWriteRenderingParams **params)
......
...@@ -1029,7 +1029,8 @@ static HRESULT opentype_type1_analyzer(IDWriteFontFileStream *stream, UINT32 *fo ...@@ -1029,7 +1029,8 @@ static HRESULT opentype_type1_analyzer(IDWriteFontFileStream *stream, UINT32 *fo
return *file_type != DWRITE_FONT_FILE_TYPE_UNKNOWN ? S_OK : S_FALSE; return *file_type != DWRITE_FONT_FILE_TYPE_UNKNOWN ? S_OK : S_FALSE;
} }
HRESULT opentype_analyze_font(IDWriteFontFileStream *stream, UINT32* font_count, DWRITE_FONT_FILE_TYPE *file_type, DWRITE_FONT_FACE_TYPE *face_type, BOOL *supported) HRESULT opentype_analyze_font(IDWriteFontFileStream *stream, BOOL *supported, DWRITE_FONT_FILE_TYPE *file_type,
DWRITE_FONT_FACE_TYPE *face_type, UINT32 *face_count)
{ {
static dwrite_fontfile_analyzer fontfile_analyzers[] = { static dwrite_fontfile_analyzer fontfile_analyzers[] = {
opentype_ttf_analyzer, opentype_ttf_analyzer,
...@@ -1047,10 +1048,10 @@ HRESULT opentype_analyze_font(IDWriteFontFileStream *stream, UINT32* font_count, ...@@ -1047,10 +1048,10 @@ HRESULT opentype_analyze_font(IDWriteFontFileStream *stream, UINT32* font_count,
*file_type = DWRITE_FONT_FILE_TYPE_UNKNOWN; *file_type = DWRITE_FONT_FILE_TYPE_UNKNOWN;
*face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN; *face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN;
*font_count = 0; *face_count = 0;
while (*analyzer) { while (*analyzer) {
hr = (*analyzer)(stream, font_count, file_type, face_type); hr = (*analyzer)(stream, face_count, file_type, face_type);
if (FAILED(hr)) if (FAILED(hr))
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