[pango/pango1-dwrite] PangoWin32: Also use DirectWrite for font descriptions on LOGFONTA's
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango1-dwrite] PangoWin32: Also use DirectWrite for font descriptions on LOGFONTA's
- Date: Tue, 16 Aug 2022 08:06:06 +0000 (UTC)
commit 2b7f2310675158cce79c97efa751967e1b8aad58
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Aug 16 16:01:24 2022 +0800
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.
pango/pangowin32-fontmap.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
---
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 1d2040b03..4cc95787a 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -1196,6 +1196,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)
@@ -1356,6 +1358,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:
@@ -1379,6 +1382,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;
@@ -1413,8 +1444,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)
{
@@ -1541,6 +1576,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:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]