Module: wine Branch: master Commit: 730b2f4c6671f489b0638a0ca766f527da15850e URL: http://source.winehq.org/git/wine.git/?a=commit;h=730b2f4c6671f489b0638a0ca7...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Dec 9 09:58:14 2014 +0300
dwrite: Implement IsMonospacedFont().
---
dlls/dwrite/dwrite_private.h | 1 + dlls/dwrite/font.c | 4 +-- dlls/dwrite/freetype.c | 20 +++++++++++++++ dlls/dwrite/tests/font.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 181a0a0..ed02501 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -129,6 +129,7 @@ extern BOOL init_freetype(void) DECLSPEC_HIDDEN; extern void release_freetype(void) DECLSPEC_HIDDEN; extern HRESULT freetype_get_design_glyph_metrics(IDWriteFontFace2*,UINT16,UINT16,DWRITE_GLYPH_METRICS*) DECLSPEC_HIDDEN; extern void freetype_notify_cacheremove(IDWriteFontFace2*) DECLSPEC_HIDDEN; +extern BOOL freetype_is_monospaced(IDWriteFontFace2*) DECLSPEC_HIDDEN;
/* Glyph shaping */ enum SCRIPT_JUSTIFY diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index e7712d7..ef4c32c 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -495,8 +495,8 @@ static HRESULT WINAPI dwritefontface1_GetUnicodeRanges(IDWriteFontFace2 *iface, static BOOL WINAPI dwritefontface1_IsMonospacedFont(IDWriteFontFace2 *iface) { struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface); - FIXME("(%p): stub\n", This); - return FALSE; + TRACE("(%p)\n", This); + return freetype_is_monospaced(iface); }
static HRESULT WINAPI dwritefontface1_GetDesignGlyphAdvances(IDWriteFontFace2 *iface, diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c index 66dd1c9..7e8fd3c 100644 --- a/dlls/dwrite/freetype.c +++ b/dlls/dwrite/freetype.c @@ -67,6 +67,7 @@ MAKE_FUNCPTR(FT_Load_Glyph); MAKE_FUNCPTR(FT_New_Memory_Face); MAKE_FUNCPTR(FTC_Manager_New); MAKE_FUNCPTR(FTC_Manager_Done); +MAKE_FUNCPTR(FTC_Manager_LookupFace); MAKE_FUNCPTR(FTC_Manager_LookupSize); MAKE_FUNCPTR(FTC_Manager_RemoveFaceID); #undef MAKE_FUNCPTR @@ -135,6 +136,7 @@ BOOL init_freetype(void) LOAD_FUNCPTR(FT_New_Memory_Face) LOAD_FUNCPTR(FTC_Manager_New) LOAD_FUNCPTR(FTC_Manager_Done) + LOAD_FUNCPTR(FTC_Manager_LookupFace) LOAD_FUNCPTR(FTC_Manager_LookupSize) LOAD_FUNCPTR(FTC_Manager_RemoveFaceID) #undef LOAD_FUNCPTR @@ -210,6 +212,19 @@ HRESULT freetype_get_design_glyph_metrics(IDWriteFontFace2 *fontface, UINT16 uni return S_OK; }
+BOOL freetype_is_monospaced(IDWriteFontFace2 *fontface) +{ + BOOL is_monospaced = FALSE; + FT_Face face; + + EnterCriticalSection(&freetype_cs); + if (pFTC_Manager_LookupFace(cache_manager, fontface, &face) == 0) + is_monospaced = FT_IS_FIXED_WIDTH(face); + LeaveCriticalSection(&freetype_cs); + + return is_monospaced; +} + #else /* HAVE_FREETYPE */
BOOL init_freetype(void) @@ -230,4 +245,9 @@ HRESULT freetype_get_design_glyph_metrics(IDWriteFontFace2 *fontface, UINT16 uni return E_NOTIMPL; }
+BOOL freetype_is_monospaced(IDWriteFontFace2 *fontface) +{ + return FALSE; +} + #endif /* HAVE_FREETYPE */ diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 58b536e..db554eb 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -2578,6 +2578,64 @@ static void test_GetDesignGlyphMetrics(void) DeleteFileW(test_fontfile); }
+static void test_IsMonospacedFont(void) +{ + static const WCHAR courierW[] = {'C','o','u','r','i','e','r',' ','N','e','w',0}; + IDWriteFontCollection *collection; + IDWriteFactory *factory; + UINT32 index; + BOOL exists; + HRESULT hr; + + factory = create_factory(); + hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE); + ok(hr == S_OK, "got 0x%08x\n", hr); + + exists = FALSE; + hr = IDWriteFontCollection_FindFamilyName(collection, courierW, &index, &exists); + ok(hr == S_OK, "got 0x%08x\n", hr); + if (exists) { + IDWriteFontFamily *family; + IDWriteFont1 *font1; + IDWriteFont *font; + + hr = IDWriteFontCollection_GetFontFamily(collection, index, &family); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL, + DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font); + ok(hr == S_OK, "got 0x%08x\n", hr); + IDWriteFontFamily_Release(family); + + hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont1, (void**)&font1); + if (hr == S_OK) { + IDWriteFontFace1 *fontface1; + IDWriteFontFace *fontface; + BOOL is_monospaced; + + is_monospaced = IDWriteFont1_IsMonospacedFont(font1); + ok(is_monospaced, "got %d\n", is_monospaced); + + hr = IDWriteFont1_CreateFontFace(font1, &fontface); + ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace1, (void**)&fontface1); + ok(hr == S_OK, "got 0x%08x\n", hr); + is_monospaced = IDWriteFontFace1_IsMonospacedFont(fontface1); + ok(is_monospaced, "got %d\n", is_monospaced); + IDWriteFontFace1_Release(fontface1); + + IDWriteFontFace_Release(fontface); + IDWriteFont1_Release(font1); + } + else + win_skip("IsMonospacedFont() is not supported.\n"); + } + else + skip("Courier New font not found.\n"); + + IDWriteFontCollection_Release(collection); +} + START_TEST(font) { IDWriteFactory *factory; @@ -2612,6 +2670,7 @@ START_TEST(font) test_CreateStreamFromKey(); test_ReadFileFragment(); test_GetDesignGlyphMetrics(); + test_IsMonospacedFont();
IDWriteFactory_Release(factory); }