summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2022-08-15 17:35:09 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2022-09-26 11:04:26 +0800
commitbbd537da6aa8abe41f79a54bcb695651071a342a (patch)
tree1ee1364103b26ac56069de978ca64985be963ad0
parent7a623b7065cd519bc4eab95aeb381f54023d4a3b (diff)
downloadpango-bbd537da6aa8abe41f79a54bcb695651071a342a.tar.gz
PangoCairo: Create cairo_font_face_t using DirectWrite
...if Cairo is built with DirectWrite support. With this, we can support colored Emoji, a long-standing issue, on Windows without needing to use FontConfig, on Windows 8.1 or later, since DirectWrite added support for colored Emoji starting with Windows 8.1. This will really fix issue !302 completely, regarding the Emoji not shown in color!
-rw-r--r--pango/pangocairo-win32font.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/pango/pangocairo-win32font.c b/pango/pangocairo-win32font.c
index 5b860bab..0141c414 100644
--- a/pango/pangocairo-win32font.c
+++ b/pango/pangocairo-win32font.c
@@ -75,6 +75,32 @@ pango_cairo_win32_font_create_font_face (PangoCairoFont *font)
{
PangoCairoWin32Font *cwfont = PANGO_CAIRO_WIN32_FONT (font);
PangoWin32Font *win32font = &cwfont->font;
+ void *dwrite_font_face = NULL;
+ gpointer dwrite_font = NULL;
+
+#ifdef HAVE_CAIRO_WIN32_DIRECTWRITE
+ dwrite_font_face = pango_win32_font_get_dwrite_font_face (win32font);
+ if (dwrite_font_face != NULL)
+ {
+ cairo_font_face_t *cairo_face = cairo_dwrite_font_face_create_for_dwrite_fontface (dwrite_font_face);
+
+ if (cairo_face != NULL)
+ {
+ static const cairo_user_data_key_t key;
+
+ cairo_font_face_set_user_data (cairo_face, &key,
+ dwrite_font_face,
+ (cairo_destroy_func_t) pango_win32_dwrite_font_face_release);
+
+ return cairo_face;
+ }
+ else
+ {
+ g_warning ("cairo_font_face creation failed with DirectWrite, fallback to GDI");
+ pango_win32_dwrite_font_face_release (dwrite_font_face);
+ }
+ }
+#endif
return cairo_win32_font_face_create_for_logfontw (&win32font->logfontw);
}