Commit 2b962761 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Use common structure to pass stream/facetype/index data around.

parent 5dc5bb75
......@@ -188,20 +188,26 @@ struct dwrite_font_props {
DWRITE_PANOSE panose;
};
struct file_stream_desc {
IDWriteFontFileStream *stream;
DWRITE_FONT_FACE_TYPE face_type;
UINT32 face_index;
};
extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,UINT32*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,BOOL*) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_font_table(IDWriteFontFileStream*,DWRITE_FONT_FACE_TYPE,UINT32,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 void opentype_get_font_properties(IDWriteFontFileStream*,DWRITE_FONT_FACE_TYPE,UINT32,struct dwrite_font_props*) DECLSPEC_HIDDEN;
extern void opentype_get_font_metrics(IDWriteFontFileStream*,DWRITE_FONT_FACE_TYPE,UINT32,DWRITE_FONT_METRICS1*,DWRITE_CARET_METRICS*) DECLSPEC_HIDDEN;
extern void opentype_get_font_properties(struct file_stream_desc*,struct dwrite_font_props*) DECLSPEC_HIDDEN;
extern void opentype_get_font_metrics(struct file_stream_desc*,DWRITE_FONT_METRICS1*,DWRITE_CARET_METRICS*) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_font_info_strings(const void*,DWRITE_INFORMATIONAL_STRING_ID,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_font_familyname(IDWriteFontFileStream*,DWRITE_FONT_FACE_TYPE,UINT32,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_font_facename(IDWriteFontFileStream*,DWRITE_FONT_FACE_TYPE,UINT32,IDWriteLocalizedStrings**) 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*,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_typographic_features(IDWriteFontFace*,UINT32,UINT32,UINT32,UINT32*,DWRITE_FONT_FEATURE_TAG*) DECLSPEC_HIDDEN;
extern BOOL opentype_get_vdmx_size(const void*,INT,UINT16*,UINT16*) DECLSPEC_HIDDEN;
extern UINT32 opentype_get_cpal_palettecount(const void*) DECLSPEC_HIDDEN;
extern UINT32 opentype_get_cpal_paletteentrycount(const void*) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_cpal_entries(const void*,UINT32,UINT32,UINT32,DWRITE_COLOR_F*) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_font_signature(IDWriteFontFileStream*,DWRITE_FONT_FACE_TYPE,UINT32,FONTSIGNATURE*) DECLSPEC_HIDDEN;
extern HRESULT opentype_get_font_signature(struct file_stream_desc*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
struct dwrite_colorglyph {
USHORT layer; /* [0, num_layers) index indicating current layer */
......
......@@ -612,10 +612,14 @@ static HRESULT WINAPI dwritefontface_TryGetFontTable(IDWriteFontFace3 *iface, UI
const void **table_data, UINT32 *table_size, void **context, BOOL *exists)
{
struct dwrite_fontface *This = impl_from_IDWriteFontFace3(iface);
struct file_stream_desc stream_desc;
TRACE("(%p)->(%s %p %p %p %p)\n", This, debugstr_tag(table_tag), table_data, table_size, context, exists);
return opentype_get_font_table(This->streams[0], This->type, This->index, table_tag, table_data, context, table_size, exists);
stream_desc.stream = This->streams[0];
stream_desc.face_type = This->type;
stream_desc.face_index = This->index;
return opentype_get_font_table(&stream_desc, table_tag, table_data, context, table_size, exists);
}
static void WINAPI dwritefontface_ReleaseFontTable(IDWriteFontFace3 *iface, void *table_context)
......@@ -3054,6 +3058,7 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA
static HRESULT init_font_data(IDWriteFactory3 *factory, IDWriteFontFile *file, DWRITE_FONT_FACE_TYPE face_type, UINT32 face_index,
IDWriteLocalizedStrings **family_name, struct dwrite_font_data **ret)
{
struct file_stream_desc stream_desc;
struct dwrite_font_props props;
struct dwrite_font_data *data;
IDWriteFontFileStream *stream;
......@@ -3082,12 +3087,15 @@ static HRESULT init_font_data(IDWriteFactory3 *factory, IDWriteFontFile *file, D
IDWriteFontFile_AddRef(file);
IDWriteFactory3_AddRef(factory);
opentype_get_font_properties(stream, face_type, face_index, &props);
opentype_get_font_metrics(stream, face_type, face_index, &data->metrics, NULL);
opentype_get_font_facename(stream, face_type, face_index, &data->names);
stream_desc.stream = stream;
stream_desc.face_type = face_type;
stream_desc.face_index = face_index;
opentype_get_font_properties(&stream_desc, &props);
opentype_get_font_metrics(&stream_desc, &data->metrics, NULL);
opentype_get_font_facename(&stream_desc, &data->names);
/* get family name from font file */
hr = opentype_get_font_familyname(stream, face_type, face_index, family_name);
hr = opentype_get_font_familyname(&stream_desc, family_name);
IDWriteFontFileStream_Release(stream);
if (FAILED(hr)) {
WARN("unable to get family name from font\n");
......@@ -4006,6 +4014,7 @@ static HRESULT get_stream_from_file(IDWriteFontFile *file, IDWriteFontFileStream
HRESULT create_fontface(DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDWriteFontFile* const* font_files, UINT32 index,
DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFace3 **ret)
{
struct file_stream_desc stream_desc;
struct dwrite_fontface *fontface;
HRESULT hr = S_OK;
int i;
......@@ -4055,7 +4064,10 @@ HRESULT create_fontface(DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDW
IDWriteFontFile_AddRef(font_files[i]);
}
opentype_get_font_metrics(fontface->streams[0], facetype, index, &fontface->metrics, &fontface->caret);
stream_desc.stream = fontface->streams[0];
stream_desc.face_type = facetype;
stream_desc.face_index = index;
opentype_get_font_metrics(&stream_desc, &fontface->metrics, &fontface->caret);
if (simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE) {
/* TODO: test what happens if caret is already slanted */
if (fontface->caret.slopeRise == 1) {
......
......@@ -682,7 +682,7 @@ static HRESULT WINAPI gdiinterop_ConvertFontFaceToLOGFONT(IDWriteGdiInterop1 *if
struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface);
IDWriteLocalizedStrings *familynames;
DWRITE_FONT_SIMULATIONS simulations;
DWRITE_FONT_FACE_TYPE face_type;
struct file_stream_desc stream_desc;
struct dwrite_font_props props;
IDWriteFontFileStream *stream;
IDWriteFontFile *file = NULL;
......@@ -705,10 +705,11 @@ static HRESULT WINAPI gdiinterop_ConvertFontFaceToLOGFONT(IDWriteGdiInterop1 *if
return hr;
}
index = IDWriteFontFace_GetIndex(fontface);
face_type = IDWriteFontFace_GetType(fontface);
opentype_get_font_properties(stream, face_type, index, &props);
hr = opentype_get_font_familyname(stream, index, face_type, &familynames);
stream_desc.stream = stream;
stream_desc.face_type = IDWriteFontFace_GetType(fontface);
stream_desc.face_index = IDWriteFontFace_GetIndex(fontface);
opentype_get_font_properties(&stream_desc, &props);
hr = opentype_get_font_familyname(&stream_desc, &familynames);
IDWriteFontFile_Release(file);
IDWriteFontFileStream_Release(stream);
if (FAILED(hr))
......@@ -884,6 +885,7 @@ static HRESULT WINAPI gdiinterop1_GetFontSignature_(IDWriteGdiInterop1 *iface, I
FONTSIGNATURE *fontsig)
{
struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface);
struct file_stream_desc stream_desc;
IDWriteFontFileStream *stream;
IDWriteFontFile *file;
UINT32 count;
......@@ -900,8 +902,10 @@ static HRESULT WINAPI gdiinterop1_GetFontSignature_(IDWriteGdiInterop1 *iface, I
if (FAILED(hr))
return hr;
hr = opentype_get_font_signature(stream, IDWriteFontFace_GetType(fontface),
IDWriteFontFace_GetIndex(fontface), fontsig);
stream_desc.stream = stream;
stream_desc.face_type = IDWriteFontFace_GetType(fontface);
stream_desc.face_index = IDWriteFontFace_GetIndex(fontface);
hr = opentype_get_font_signature(&stream_desc, fontsig);
IDWriteFontFileStream_Release(stream);
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