Nikolay Sivov : dwrite: Implement IsSymbolFont().
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Aug 6 10:15:44 CDT 2015
Module: wine
Branch: master
Commit: ab7c65ae436fa5027846184c5b4fb6b56aee9ab8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ab7c65ae436fa5027846184c5b4fb6b56aee9ab8
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Thu Aug 6 18:02:43 2015 +0300
dwrite: Implement IsSymbolFont().
---
dlls/dwrite/dwrite_private.h | 1 +
dlls/dwrite/font.c | 7 +++++--
dlls/dwrite/freetype.c | 43 ++++++++++++++++++++++++++++++++++++++++++
dlls/dwrite/tests/font.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 75098cf..cee49df 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -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
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index aaa0f42..a4ed575 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -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;
diff --git a/dlls/dwrite/freetype.c b/dlls/dwrite/freetype.c
index 2c02b26..e693f9a 100644
--- a/dlls/dwrite/freetype.c
+++ b/dlls/dwrite/freetype.c
@@ -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 */
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 327a29f..9a75abc 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -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);
}
More information about the wine-cvs
mailing list