dwrite: Implement IsSymbolFont().

This commit is contained in:
Nikolay Sivov 2015-08-06 18:02:43 +03:00 committed by Alexandre Julliard
parent 7540fa5a1a
commit ab7c65ae43
4 changed files with 94 additions and 2 deletions

View File

@ -195,6 +195,7 @@ extern BOOL freetype_has_kerning_pairs(IDWriteFontFace2*) DECLSPEC_HIDDEN;
extern INT32 freetype_get_kerning_pair_adjustment(IDWriteFontFace2*,UINT16,UINT16) DECLSPEC_HIDDEN;
extern void freetype_get_glyph_bbox(IDWriteFontFace2*,FLOAT,UINT16,BOOL,RECT*) DECLSPEC_HIDDEN;
extern void freetype_get_glyph_bitmap(IDWriteFontFace2*,FLOAT,UINT16,const RECT*,BYTE*) DECLSPEC_HIDDEN;
extern INT freetype_get_charmap_index(IDWriteFontFace2*,BOOL*) DECLSPEC_HIDDEN;
/* Glyph shaping */
enum SCRIPT_JUSTIFY

View File

@ -148,6 +148,8 @@ struct dwrite_fontface {
DWRITE_FONT_FACE_TYPE type;
DWRITE_FONT_METRICS1 metrics;
DWRITE_CARET_METRICS caret;
INT charmap;
BOOL is_symbol;
struct dwrite_fonttable cmap;
struct dwrite_fonttable vdmx;
@ -401,8 +403,8 @@ static DWRITE_FONT_SIMULATIONS WINAPI dwritefontface_GetSimulations(IDWriteFontF
static BOOL WINAPI dwritefontface_IsSymbolFont(IDWriteFontFace2 *iface)
{
struct dwrite_fontface *This = impl_from_IDWriteFontFace2(iface);
FIXME("(%p): stub\n", This);
return FALSE;
TRACE("(%p)\n", This);
return This->is_symbol;
}
static void WINAPI dwritefontface_GetMetrics(IDWriteFontFace2 *iface, DWRITE_FONT_METRICS *metrics)
@ -2500,6 +2502,7 @@ HRESULT create_fontface(DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDW
fontface->caret.slopeRun = fontface->caret.slopeRise / 3;
}
}
fontface->charmap = freetype_get_charmap_index(&fontface->IDWriteFontFace2_iface, &fontface->is_symbol);
*ret = &fontface->IDWriteFontFace2_iface;
return S_OK;

View File

@ -28,6 +28,7 @@
#include FT_CACHE_H
#include FT_FREETYPE_H
#include FT_OUTLINE_H
#include FT_TRUETYPE_TABLES_H
#endif /* HAVE_FT2BUILD_H */
#include "windef.h"
@ -64,7 +65,9 @@ typedef struct
#define MAKE_FUNCPTR(f) static typeof(f) * p##f = NULL
MAKE_FUNCPTR(FT_Done_FreeType);
MAKE_FUNCPTR(FT_Get_First_Char);
MAKE_FUNCPTR(FT_Get_Kerning);
MAKE_FUNCPTR(FT_Get_Sfnt_Table);
MAKE_FUNCPTR(FT_Glyph_Get_CBox);
MAKE_FUNCPTR(FT_Init_FreeType);
MAKE_FUNCPTR(FT_Library_Version);
@ -145,7 +148,9 @@ BOOL init_freetype(void)
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(ft_handle, #f, NULL, 0)) == NULL){WARN("Can't find symbol %s\n", #f); goto sym_not_found;}
LOAD_FUNCPTR(FT_Done_FreeType)
LOAD_FUNCPTR(FT_Get_First_Char)
LOAD_FUNCPTR(FT_Get_Kerning)
LOAD_FUNCPTR(FT_Get_Sfnt_Table)
LOAD_FUNCPTR(FT_Glyph_Get_CBox)
LOAD_FUNCPTR(FT_Init_FreeType)
LOAD_FUNCPTR(FT_Library_Version)
@ -554,6 +559,38 @@ void freetype_get_glyph_bitmap(IDWriteFontFace2 *fontface, FLOAT emSize, UINT16
LeaveCriticalSection(&freetype_cs);
}
INT freetype_get_charmap_index(IDWriteFontFace2 *fontface, BOOL *is_symbol)
{
INT charmap_index = -1;
FT_Face face;
*is_symbol = FALSE;
EnterCriticalSection(&freetype_cs);
if (pFTC_Manager_LookupFace(cache_manager, fontface, &face) == 0) {
TT_OS2 *os2 = pFT_Get_Sfnt_Table(face, ft_sfnt_os2);
FT_Int i;
if (os2) {
FT_UInt dummy;
if (os2->version == 0)
*is_symbol = pFT_Get_First_Char(face, &dummy) >= 0x100;
else
*is_symbol = os2->ulCodePageRange1 & FS_SYMBOL;
}
for (i = 0; i < face->num_charmaps; i++)
if (face->charmaps[i]->encoding == FT_ENCODING_MS_SYMBOL) {
*is_symbol = TRUE;
charmap_index = i;
break;
}
}
LeaveCriticalSection(&freetype_cs);
return charmap_index;
}
#else /* HAVE_FREETYPE */
BOOL init_freetype(void)
@ -616,4 +653,10 @@ void freetype_get_glyph_bitmap(IDWriteFontFace2 *fontface, FLOAT emSize, UINT16
memset(buf, 0, size);
}
INT freetype_get_charmap_index(IDWriteFontFace2 *fontface, BOOL *is_symbol)
{
*is_symbol = FALSE;
return -1;
}
#endif /* HAVE_FREETYPE */

View File

@ -4710,6 +4710,50 @@ static void test_CreateAlphaTexture(void)
IDWriteFactory_Release(factory);
}
static void test_IsSymbolFont(void)
{
static const WCHAR symbolW[] = {'S','y','m','b','o','l',0};
IDWriteFontCollection *collection;
IDWriteFontFace *fontface;
IDWriteFactory *factory;
IDWriteFont *font;
HRESULT hr;
BOOL ret;
factory = create_factory();
/* Tahoma */
fontface = create_fontface(factory);
ret = IDWriteFontFace_IsSymbolFont(fontface);
ok(!ret, "got %d\n", ret);
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteFontCollection_GetFontFromFontFace(collection, fontface, &font);
ok(hr == S_OK, "got 0x%08x\n", hr);
ret = IDWriteFont_IsSymbolFont(font);
ok(!ret, "got %d\n", ret);
IDWriteFontCollection_Release(collection);
IDWriteFont_Release(font);
IDWriteFontFace_Release(fontface);
/* Symbol */
font = get_font(factory, symbolW, DWRITE_FONT_STYLE_NORMAL);
ret = IDWriteFont_IsSymbolFont(font);
ok(ret, "got %d\n", ret);
hr = IDWriteFont_CreateFontFace(font, &fontface);
ok(hr == S_OK, "got 0x%08x\n", hr);
ret = IDWriteFontFace_IsSymbolFont(fontface);
ok(ret, "got %d\n", ret);
IDWriteFont_Release(font);
IDWriteFactory_Release(factory);
}
START_TEST(font)
{
IDWriteFactory *factory;
@ -4759,6 +4803,7 @@ START_TEST(font)
test_GetRecommendedRenderingMode();
test_GetAlphaBlendParams();
test_CreateAlphaTexture();
test_IsSymbolFont();
IDWriteFactory_Release(factory);
}