Module: wine Branch: master Commit: c949ff5d24b72a74e517d936db9bc45866a4d047 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c949ff5d24b72a74e517d936db...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Thu Feb 5 15:54:05 2015 +0300
dwrite: Implement GetGlyphCount().
---
dlls/dwrite/dwrite_private.h | 1 + dlls/dwrite/font.c | 4 ++-- dlls/dwrite/freetype.c | 18 ++++++++++++++++++ dlls/dwrite/tests/font.c | 31 ++++++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index ce7aad5..674e9f0 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -160,6 +160,7 @@ extern HRESULT freetype_get_design_glyph_metrics(IDWriteFontFace2*,UINT16,UINT16 extern void freetype_notify_cacheremove(IDWriteFontFace2*) DECLSPEC_HIDDEN; extern BOOL freetype_is_monospaced(IDWriteFontFace2*) DECLSPEC_HIDDEN; extern HRESULT freetype_get_glyph_outline(IDWriteFontFace2*,FLOAT,UINT16,USHORT,struct glyph_outline**) DECLSPEC_HIDDEN; +extern UINT16 freetype_get_glyphcount(IDWriteFontFace2*) DECLSPEC_HIDDEN;
/* Glyph shaping */ enum SCRIPT_JUSTIFY diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 1f1f367..e3480ec 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -349,8 +349,8 @@ static void WINAPI dwritefontface_GetMetrics(IDWriteFontFace2 *iface, DWRITE_FON static UINT16 WINAPI dwritefontface_GetGlyphCount(IDWriteFontFace2 *iface) { struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface); - FIXME("(%p): stub\n", This); - return 0; + TRACE("(%p)\n", This); + return freetype_get_glyphcount(iface); }
static HRESULT WINAPI dwritefontface_GetDesignGlyphMetrics(IDWriteFontFace2 *iface, diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c index 43fa4df..3b9681d 100644 --- a/dlls/dwrite/freetype.c +++ b/dlls/dwrite/freetype.c @@ -375,6 +375,19 @@ HRESULT freetype_get_glyph_outline(IDWriteFontFace2 *fontface, FLOAT emSize, UIN return hr; }
+UINT16 freetype_get_glyphcount(IDWriteFontFace2 *fontface) +{ + UINT16 count = 0; + FT_Face face; + + EnterCriticalSection(&freetype_cs); + if (pFTC_Manager_LookupFace(cache_manager, fontface, &face) == 0) + count = face->num_glyphs; + LeaveCriticalSection(&freetype_cs); + + return count; +} + #else /* HAVE_FREETYPE */
BOOL init_freetype(void) @@ -406,4 +419,9 @@ HRESULT freetype_get_glyph_outline(IDWriteFontFace2 *fontface, FLOAT emSize, UIN return E_NOTIMPL; }
+UINT16 freetype_get_glyphcount(IDWriteFontFace2 *fontface) +{ + return 0; +} + #endif /* HAVE_FREETYPE */ diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 915fb98..ca31f29 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -75,7 +75,7 @@ static void create_testfontfile(const WCHAR *filename) HRSRC res; void *ptr; file = CreateFileW(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 ); - ok( file != INVALID_HANDLE_VALUE, "file creation failed\n" ); + ok(file != INVALID_HANDLE_VALUE, "file creation failed, error %d\n", GetLastError());
res = FindResourceA(GetModuleHandleA(NULL), (LPCSTR)MAKEINTRESOURCE(1), (LPCSTR)RT_RCDATA); ok( res != 0, "couldn't find resource\n" ); @@ -2994,8 +2994,10 @@ static void test_GetCaretMetrics(void) ok(caret.slopeRun == 0, "got %d\n", caret.slopeRun); ok(caret.offset == 0, "got %d\n", caret.offset); IDWriteFontFace1_Release(fontface1); + IDWriteFactory_Release(factory);
/* now with Tahoma Normal */ + factory = create_factory(); font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL); hr = IDWriteFont_CreateFontFace(font, &fontface); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -3033,6 +3035,32 @@ static void test_GetCaretMetrics(void) DeleteFileW(test_fontfile); }
+static void test_GetGlyphCount(void) +{ + IDWriteFontFace *fontface; + IDWriteFactory *factory; + IDWriteFontFile *file; + HRESULT hr; + UINT16 count; + + create_testfontfile(test_fontfile); + factory = create_factory(); + + hr = IDWriteFactory_CreateFontFileReference(factory, test_fontfile, NULL, &file); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDWriteFactory_CreateFontFace(factory, DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &file, 0, DWRITE_FONT_SIMULATIONS_NONE, &fontface); + ok(hr == S_OK, "got 0x%08x\n", hr); + IDWriteFontFile_Release(file); + + count = IDWriteFontFace_GetGlyphCount(fontface); + ok(count == 7, "got %u\n", count); + + IDWriteFontFace_Release(fontface); + IDWriteFactory_Release(factory); + DeleteFileW(test_fontfile); +} + START_TEST(font) { IDWriteFactory *factory; @@ -3072,6 +3100,7 @@ START_TEST(font) test_GetGlyphRunOutline(); test_GetEudcFontCollection(); test_GetCaretMetrics(); + test_GetGlyphCount();
IDWriteFactory_Release(factory); }