[PATCH 3/3] dwrite: Simplify GetFontSignature()
Nikolay Sivov
nsivov at codeweavers.com
Tue Aug 15 06:40:26 CDT 2017
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/dwrite/dwrite_private.h | 4 +++-
dlls/dwrite/font.c | 19 +++++++++++++++++++
dlls/dwrite/gdiinterop.c | 33 ++-------------------------------
dlls/dwrite/opentype.c | 44 ++++++++++++++++----------------------------
4 files changed, 40 insertions(+), 60 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index c65166dd05..a0632b7771 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -202,6 +202,8 @@ extern void factory_detach_gdiinterop(IDWriteFactory5*,IDWriteGdiInterop1*) DECL
extern struct fontfacecached *factory_cache_fontface(IDWriteFactory5*,struct list*,IDWriteFontFace4*) DECLSPEC_HIDDEN;
extern void get_logfont_from_font(IDWriteFont*,LOGFONTW*) DECLSPEC_HIDDEN;
extern void get_logfont_from_fontface(IDWriteFontFace*,LOGFONTW*) DECLSPEC_HIDDEN;
+extern HRESULT get_fontsig_from_font(IDWriteFont*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
+extern HRESULT get_fontsig_from_fontface(IDWriteFontFace*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
extern HRESULT create_gdiinterop(IDWriteFactory5*,IDWriteGdiInterop1**) DECLSPEC_HIDDEN;
extern void fontface_detach_from_cache(IDWriteFontFace4*) DECLSPEC_HIDDEN;
extern void factory_lock(IDWriteFactory5*) DECLSPEC_HIDDEN;
@@ -213,6 +215,7 @@ struct dwrite_font_props {
DWRITE_FONT_STRETCH stretch;
DWRITE_FONT_WEIGHT weight;
DWRITE_PANOSE panose;
+ FONTSIGNATURE fontsig;
LOGFONTW lf;
};
@@ -235,7 +238,6 @@ extern BOOL opentype_get_vdmx_size(const void*,INT,UINT16*,UINT16*) DECLSPEC_HID
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(struct file_stream_desc*,FONTSIGNATURE*) DECLSPEC_HIDDEN;
extern BOOL opentype_has_vertical_variants(IDWriteFontFace4*) DECLSPEC_HIDDEN;
extern UINT32 opentype_get_glyph_image_formats(IDWriteFontFace4*) DECLSPEC_HIDDEN;
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index a189f74377..4dfb47fc7e 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -76,6 +76,7 @@ struct dwrite_font_data {
DWRITE_FONT_STRETCH stretch;
DWRITE_FONT_WEIGHT weight;
DWRITE_PANOSE panose;
+ FONTSIGNATURE fontsig;
struct dwrite_font_propvec propvec;
DWRITE_FONT_METRICS1 metrics;
@@ -242,6 +243,7 @@ struct dwrite_fontface {
DWRITE_FONT_STRETCH stretch;
DWRITE_FONT_WEIGHT weight;
DWRITE_PANOSE panose;
+ FONTSIGNATURE fontsig;
UINT32 glyph_image_formats;
LOGFONTW lf;
@@ -1769,6 +1771,20 @@ void get_logfont_from_fontface(IDWriteFontFace *iface, LOGFONTW *lf)
*lf = fontface->lf;
}
+HRESULT get_fontsig_from_font(IDWriteFont *iface, FONTSIGNATURE *fontsig)
+{
+ struct dwrite_font *font = unsafe_impl_from_IDWriteFont(iface);
+ *fontsig = font->data->fontsig;
+ return S_OK;
+}
+
+HRESULT get_fontsig_from_fontface(IDWriteFontFace *iface, FONTSIGNATURE *fontsig)
+{
+ struct dwrite_fontface *fontface = unsafe_impl_from_IDWriteFontFace(iface);
+ *fontsig = fontface->fontsig;
+ return S_OK;
+}
+
static HRESULT create_font(struct dwrite_fontfamily *family, UINT32 index, IDWriteFont3 **font)
{
struct dwrite_font *This;
@@ -3344,6 +3360,7 @@ static HRESULT init_font_data(const struct fontface_desc *desc, IDWriteLocalized
data->stretch = props.stretch;
data->weight = props.weight;
data->panose = props.panose;
+ data->fontsig = props.fontsig;
data->lf = props.lf;
fontstrings_get_en_string(*family_name, familyW, sizeof(familyW)/sizeof(WCHAR));
@@ -4383,6 +4400,7 @@ HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_li
fontface->style = desc->font_data->style;
fontface->stretch = desc->font_data->stretch;
fontface->panose = desc->font_data->panose;
+ fontface->fontsig = desc->font_data->fontsig;
fontface->lf = desc->font_data->lf;
}
else {
@@ -4399,6 +4417,7 @@ HRESULT create_fontface(const struct fontface_desc *desc, struct list *cached_li
fontface->style = data->style;
fontface->stretch = data->stretch;
fontface->panose = data->panose;
+ fontface->fontsig = data->fontsig;
fontface->lf = data->lf;
IDWriteLocalizedStrings_Release(names);
diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c
index 22b4ca482b..5425b5c4ae 100644
--- a/dlls/dwrite/gdiinterop.c
+++ b/dlls/dwrite/gdiinterop.c
@@ -838,51 +838,22 @@ 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;
- HRESULT hr;
TRACE("(%p)->(%p %p)\n", This, fontface, fontsig);
- memset(fontsig, 0, sizeof(*fontsig));
-
- count = 1;
- hr = IDWriteFontFace_GetFiles(fontface, &count, &file);
- hr = get_filestream_from_file(file, &stream);
- IDWriteFontFile_Release(file);
- if (FAILED(hr))
- return hr;
-
- 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;
+ return get_fontsig_from_fontface(fontface, fontsig);
}
static HRESULT WINAPI gdiinterop1_GetFontSignature(IDWriteGdiInterop1 *iface, IDWriteFont *font, FONTSIGNATURE *fontsig)
{
struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface);
- IDWriteFontFace *fontface;
- HRESULT hr;
TRACE("(%p)->(%p %p)\n", This, font, fontsig);
if (!font)
return E_INVALIDARG;
- memset(fontsig, 0, sizeof(*fontsig));
-
- hr = IDWriteFont_CreateFontFace(font, &fontface);
- if (FAILED(hr))
- return hr;
-
- hr = IDWriteGdiInterop1_GetFontSignature_(iface, fontface, fontsig);
- IDWriteFontFace_Release(fontface);
- return hr;
+ return get_fontsig_from_font(font, fontsig);
}
static HRESULT WINAPI gdiinterop1_GetMatchingFontsByLOGFONT(IDWriteGdiInterop1 *iface, LOGFONTW const *logfont,
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index a66500a73b..36c34b630e 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -1317,6 +1317,7 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d
props->weight = DWRITE_FONT_WEIGHT_NORMAL;
props->style = DWRITE_FONT_STYLE_NORMAL;
memset(&props->panose, 0, sizeof(props->panose));
+ memset(&props->fontsig, 0, sizeof(props->fontsig));
memset(&props->lf, 0, sizeof(props->lf));
/* DWRITE_FONT_STRETCH enumeration values directly match font data values */
@@ -1343,6 +1344,21 @@ void opentype_get_font_properties(struct file_stream_desc *stream_desc, struct d
props->style = DWRITE_FONT_STYLE_ITALIC;
memcpy(&props->panose, &tt_os2->panose, sizeof(props->panose));
+
+ /* FONTSIGNATURE */
+ props->fontsig.fsUsb[0] = GET_BE_DWORD(tt_os2->ulUnicodeRange1);
+ props->fontsig.fsUsb[1] = GET_BE_DWORD(tt_os2->ulUnicodeRange2);
+ props->fontsig.fsUsb[2] = GET_BE_DWORD(tt_os2->ulUnicodeRange3);
+ props->fontsig.fsUsb[3] = GET_BE_DWORD(tt_os2->ulUnicodeRange4);
+
+ if (GET_BE_WORD(tt_os2->version) == 0) {
+ props->fontsig.fsCsb[0] = 0;
+ props->fontsig.fsCsb[1] = 0;
+ }
+ else {
+ props->fontsig.fsCsb[0] = GET_BE_DWORD(tt_os2->ulCodePageRange1);
+ props->fontsig.fsCsb[1] = GET_BE_DWORD(tt_os2->ulCodePageRange2);
+ }
}
else if (tt_head) {
USHORT macStyle = GET_BE_WORD(tt_head->macStyle);
@@ -1971,34 +1987,6 @@ void opentype_colr_next_glyph(const void *colr, struct dwrite_colorglyph *glyph)
glyph->palette_index = GET_BE_WORD(layer->paletteIndex);
}
-HRESULT opentype_get_font_signature(struct file_stream_desc *stream_desc, FONTSIGNATURE *fontsig)
-{
- const TT_OS2_V2 *tt_os2;
- void *os2_context;
- HRESULT hr;
-
- hr = opentype_get_font_table(stream_desc, MS_OS2_TAG, (const void**)&tt_os2, &os2_context, NULL, NULL);
- if (tt_os2) {
- fontsig->fsUsb[0] = GET_BE_DWORD(tt_os2->ulUnicodeRange1);
- fontsig->fsUsb[1] = GET_BE_DWORD(tt_os2->ulUnicodeRange2);
- fontsig->fsUsb[2] = GET_BE_DWORD(tt_os2->ulUnicodeRange3);
- fontsig->fsUsb[3] = GET_BE_DWORD(tt_os2->ulUnicodeRange4);
-
- if (GET_BE_WORD(tt_os2->version) == 0) {
- fontsig->fsCsb[0] = 0;
- fontsig->fsCsb[1] = 0;
- }
- else {
- fontsig->fsCsb[0] = GET_BE_DWORD(tt_os2->ulCodePageRange1);
- fontsig->fsCsb[1] = GET_BE_DWORD(tt_os2->ulCodePageRange2);
- }
-
- IDWriteFontFileStream_ReleaseFileFragment(stream_desc->stream, os2_context);
- }
-
- return hr;
-}
-
BOOL opentype_has_vertical_variants(IDWriteFontFace4 *fontface)
{
const OT_FeatureList *featurelist;
--
2.14.1
More information about the wine-patches
mailing list