dwrite: Implement GetFontSignature().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-05-03 21:26:47 +03:00 committed by Alexandre Julliard
parent bb48b11508
commit 5dc5bb7580
4 changed files with 58 additions and 8 deletions

View File

@ -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_palettecount(const void*) DECLSPEC_HIDDEN;
extern UINT32 opentype_get_cpal_paletteentrycount(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_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 { struct dwrite_colorglyph {
USHORT layer; /* [0, num_layers) index indicating current layer */ USHORT layer; /* [0, num_layers) index indicating current layer */

View File

@ -884,19 +884,48 @@ static HRESULT WINAPI gdiinterop1_GetFontSignature_(IDWriteGdiInterop1 *iface, I
FONTSIGNATURE *fontsig) FONTSIGNATURE *fontsig)
{ {
struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); 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) static HRESULT WINAPI gdiinterop1_GetFontSignature(IDWriteGdiInterop1 *iface, IDWriteFont *font, FONTSIGNATURE *fontsig)
{ {
struct gdiinterop *This = impl_from_IDWriteGdiInterop1(iface); 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, static HRESULT WINAPI gdiinterop1_GetMatchingFontsByLOGFONT(IDWriteGdiInterop1 *iface, LOGFONTW const *logfont,

View File

@ -1869,3 +1869,26 @@ void opentype_colr_next_glyph(const void *colr, struct dwrite_colorglyph *glyph)
glyph->glyph = GET_BE_WORD(layer->GID); glyph->glyph = GET_BE_WORD(layer->GID);
glyph->palette_index = GET_BE_WORD(layer->paletteIndex); 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;
}

View File

@ -6020,7 +6020,6 @@ static void test_GetFontSignature(void)
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteGdiInterop1_GetFontSignature(interop1, NULL, &fontsig); hr = IDWriteGdiInterop1_GetFontSignature(interop1, NULL, &fontsig);
todo_wine
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE); hr = IDWriteFactory_GetSystemFontCollection(factory, &syscollection, FALSE);
@ -6053,10 +6052,8 @@ todo_wine
IDWriteLocalizedStrings_Release(names); IDWriteLocalizedStrings_Release(names);
hr = IDWriteGdiInterop1_GetFontSignature(interop1, font, &fontsig); hr = IDWriteGdiInterop1_GetFontSignature(interop1, font, &fontsig);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK) {
get_expected_fontsig(font, &expected_signature); 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), 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]); 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), 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]); fontsig.fsCsb[1], expected_signature.fsCsb[1]);
}
IDWriteFont_Release(font); IDWriteFont_Release(font);
IDWriteFontFace_Release(fontface); IDWriteFontFace_Release(fontface);
IDWriteFontFamily_Release(family); IDWriteFontFamily_Release(family);