mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 19:47:27 +00:00
dwrite: Implement IsMonospacedFont().
This commit is contained in:
parent
13a101707a
commit
730b2f4c66
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue