Nikolay Sivov : dwrite: Implement GetFontSignature().
Alexandre Julliard
julliard at wine.codeweavers.com
Wed May 4 11:38:20 CDT 2016
Module: wine
Branch: master
Commit: 5dc5bb7580f114fdf15303c7652ae35bd97fe498
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5dc5bb7580f114fdf15303c7652ae35bd97fe498
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue May 3 21:26:47 2016 +0300
dwrite: Implement GetFontSignature().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dwrite/dwrite_private.h | 1 +
dlls/dwrite/gdiinterop.c | 37 +++++++++++++++++++++++++++++++++----
dlls/dwrite/opentype.c | 23 +++++++++++++++++++++++
dlls/dwrite/tests/font.c | 5 +----
4 files changed, 58 insertions(+), 8 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 3dc29a1..d8d578b 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -201,6 +201,7 @@ 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(IDWriteFontFileStream*,DWRITE_FONT_FACE_TYPE,UINT32,FONTSIGNATURE*) DECLSPEC_HIDDEN;
struct dwrite_colorglyph {
USHORT layer; /* [0, num_layers) index indicating current layer */
diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c
index e14dfa8..41cddf2 100644
--- a/dlls/dwrite/gdiinterop.c
+++ b/dlls/dwrite/gdiinterop.c
@@ -884,19 +884,48 @@ static HRESULT WINAPI gdiinterop1_GetFontSignature_(IDWriteGdiInterop1 *iface, I
FONTSIGNATURE *fontsig)
{
struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface);
+ IDWriteFontFileStream *stream;
+ IDWriteFontFile *file;
+ UINT32 count;
+ HRESULT hr;
- FIXME("(%p)->(%p %p): stub\n", This, fontface, fontsig);
+ TRACE("(%p)->(%p %p)\n", This, fontface, fontsig);
- return E_NOTIMPL;
+ 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;
+
+ hr = opentype_get_font_signature(stream, IDWriteFontFace_GetType(fontface),
+ IDWriteFontFace_GetIndex(fontface), fontsig);
+ IDWriteFontFileStream_Release(stream);
+ return hr;
}
static HRESULT WINAPI gdiinterop1_GetFontSignature(IDWriteGdiInterop1 *iface, IDWriteFont *font, FONTSIGNATURE *fontsig)
{
struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface);
+ IDWriteFontFace *fontface;
+ HRESULT hr;
- FIXME("(%p)->(%p %p): stub\n", This, font, fontsig);
+ TRACE("(%p)->(%p %p)\n", This, font, fontsig);
- return E_NOTIMPL;
+ 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;
}
static HRESULT WINAPI gdiinterop1_GetMatchingFontsByLOGFONT(IDWriteGdiInterop1 *iface, LOGFONTW const *logfont,
diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c
index cbb372c..ec8bec7 100644
--- a/dlls/dwrite/opentype.c
+++ b/dlls/dwrite/opentype.c
@@ -1869,3 +1869,26 @@ void opentype_colr_next_glyph(const void *colr, struct dwrite_colorglyph *glyph)
glyph->glyph = GET_BE_WORD(layer->GID);
glyph->palette_index = GET_BE_WORD(layer->paletteIndex);
}
+
+HRESULT opentype_get_font_signature(IDWriteFontFileStream *stream, DWRITE_FONT_FACE_TYPE face_type, UINT32 face_index,
+ FONTSIGNATURE *fontsig)
+{
+ const TT_OS2_V2 *tt_os2;
+ void *os2_context;
+ HRESULT hr;
+
+ hr = opentype_get_font_table(stream, face_type, face_index, 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);
+
+ fontsig->fsCsb[0] = GET_BE_DWORD(tt_os2->ulCodePageRange1);
+ fontsig->fsCsb[1] = GET_BE_DWORD(tt_os2->ulCodePageRange2);
+
+ IDWriteFontFileStream_ReleaseFileFragment(stream, os2_context);
+ }
+
+ return hr;
+}
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 299607c..0ae3251 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -6020,7 +6020,6 @@ static void test_GetFontSignature(void)
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteGdiInterop1_GetFontSignature(interop1, NULL, &fontsig);
-todo_wine
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
@@ -6053,10 +6052,8 @@ todo_wine
IDWriteLocalizedStrings_Release(names);
hr = IDWriteGdiInterop1_GetFontSignature(interop1, font, &fontsig);
- todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
-if (hr == S_OK) {
get_expected_fontsig(font, &expected_signature);
ok(fontsig.fsUsb[0] == expected_signature.fsUsb[0], "%s: fsUsb[0] %#x, expected %#x\n", wine_dbgstr_w(nameW),
@@ -6072,7 +6069,7 @@ if (hr == S_OK) {
fontsig.fsCsb[0], expected_signature.fsCsb[0]);
ok(fontsig.fsCsb[1] == expected_signature.fsCsb[1], "%s: fsCsb[1] %#x, expected %#x\n", wine_dbgstr_w(nameW),
fontsig.fsCsb[1], expected_signature.fsCsb[1]);
-}
+
IDWriteFont_Release(font);
IDWriteFontFace_Release(fontface);
IDWriteFontFamily_Release(family);
More information about the wine-cvs
mailing list