summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2022-08-16 16:01:24 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2022-09-26 11:04:25 +0800
commitb406dd6e1282e7a98ed9a7b3d8b0e6af416a9797 (patch)
treeaa5827324ce905d33acae19305fca9cae3e54552
parent894821e8b4593ece2437481fd607022b36d94f1f (diff)
downloadpango-b406dd6e1282e7a98ed9a7b3d8b0e6af416a9797.tar.gz
PangoWin32: Also use DirectWrite for font descriptions on LOGFONTA's
Extend the support to use DirectWrite to query the font descriptions from LOGFONTA's, by using a temporary LOGFONTW which uses the UTF-16'fied facename converted directly using g_locale_to_utf8 (), since DirectWrite expects us to use LOGFONTW's for its GDI interop operations.
-rw-r--r--pango/pangowin32-fontmap.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 05542f74..78fd7b30 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -1195,6 +1195,8 @@ pango_win32_font_map_real_find_font (PangoWin32FontMap *win32fontmap,
return (PangoFont *)win32font;
}
+#if 0
+/* XXX: Add fallback for using GDI? */
static gboolean
_pango_win32_get_name_header (HDC hdc,
struct name_header *header)
@@ -1355,6 +1357,7 @@ get_family_nameA (const LOGFONTA *lfp)
fail0:
return g_locale_to_utf8 (lfp->lfFaceName, -1, NULL, NULL, NULL);
}
+#endif
/**
* pango_win32_font_description_from_logfont:
@@ -1378,6 +1381,34 @@ get_family_nameA (const LOGFONTA *lfp)
PangoFontDescription *
pango_win32_font_description_from_logfont (const LOGFONT *lfp)
{
+ LOGFONTW lfw;
+ PangoFontDescription *desc = NULL;
+ gchar *facename_utf8 = g_locale_to_utf8 (lfp->lfFaceName, -1, NULL, NULL, NULL);
+ wchar_t *facename_utf16 = g_utf8_to_utf16 (facename_utf8, -1, NULL, NULL, NULL);
+
+ lfw.lfHeight = lfp->lfHeight;
+ lfw.lfWidth = lfp->lfWidth;
+ lfw.lfEscapement = lfp->lfEscapement;
+ lfw.lfOrientation = lfp->lfOrientation;
+ lfw.lfWeight = lfp->lfWeight;
+ lfw.lfItalic = lfp->lfItalic;
+ lfw.lfUnderline = lfp->lfUnderline;
+ lfw.lfStrikeOut = lfp->lfStrikeOut;
+ lfw.lfCharSet = lfp->lfCharSet;
+ lfw.lfOutPrecision = lfp->lfOutPrecision;
+ lfw.lfClipPrecision = lfp->lfClipPrecision;
+ lfw.lfQuality = lfp->lfQuality;
+ lfw.lfPitchAndFamily = lfp->lfPitchAndFamily;
+ wcscpy (lfw.lfFaceName, facename_utf16);
+
+ desc = pango_win32_font_description_from_logfontw_dwrite (&lfw);
+ g_free (facename_utf16);
+ g_free (facename_utf8);
+
+ return desc;
+
+#if 0
+/* XXX: Add fallback for using GDI? */
PangoFontDescription *description;
gchar *family;
PangoStyle style;
@@ -1412,8 +1443,12 @@ pango_win32_font_description_from_logfont (const LOGFONT *lfp)
pango_font_description_set_variant (description, variant);
return description;
+#endif
}
+#if 0
+
+/* XXX: Add fallback for using GDI? */
static gchar *
get_family_nameW (const LOGFONTW *lfp)
{
@@ -1540,6 +1575,7 @@ get_family_nameW (const LOGFONTW *lfp)
fail0:
return g_utf16_to_utf8 (lfp->lfFaceName, -1, NULL, NULL, NULL);
}
+#endif
/**
* pango_win32_font_description_from_logfontw: