[pango/pango1-dwrite] PangoWin32: Split out acquiring IDWriteFont from PangoWin32Font
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango1-dwrite] PangoWin32: Split out acquiring IDWriteFont from PangoWin32Font
- Date: Fri, 12 Aug 2022 10:57:32 +0000 (UTC)
commit 1de77f2a51b930a8771a3925ba119860c0e55af7
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Thu Aug 11 12:25:14 2022 +0800
PangoWin32: Split out acquiring IDWriteFont from PangoWin32Font
This will be carried out by various functions, so we want to reuse
things.
pango/pangowin32-dwrite-fontmap.cpp | 41 ++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 12 deletions(-)
---
diff --git a/pango/pangowin32-dwrite-fontmap.cpp b/pango/pangowin32-dwrite-fontmap.cpp
index 916891c7f..15253f94f 100644
--- a/pango/pangowin32-dwrite-fontmap.cpp
+++ b/pango/pangowin32-dwrite-fontmap.cpp
@@ -422,6 +422,30 @@ pango_win32_font_description_from_logfontw_dwrite (const LOGFONTW *logfontw)
return desc;
}
+static IDWriteFont *
+get_dwrite_font_from_pango_win32_font (PangoWin32Font *font,
+ gboolean *is_cleanup_dwrite_font)
+{
+ PangoWin32DWriteItems *dwrite_items = pango_win32_get_direct_write_items ();
+ IDWriteFont *dwrite_font = NULL;
+
+ dwrite_font = (IDWriteFont *) g_hash_table_lookup (PANGO_WIN32_FONT_MAP (font->fontmap)->dwrite_fonts,
+ &font->logfontw);
+
+ /* create the IDWriteFont from the logfont underlying the PangoWin32Font if needed */
+ if (dwrite_font == NULL)
+ {
+ if (SUCCEEDED (dwrite_items->gdi_interop->CreateFontFromLOGFONT (&font->logfontw,
+ &dwrite_font)) &&
+ dwrite_font != NULL)
+ *is_cleanup_dwrite_font = TRUE;
+ else
+ dwrite_font = NULL;
+ }
+
+ return dwrite_font;
+}
+
/* macros to help parse the 'gasp' font table, referring to FreeType2 */
#define DWRITE_UCHAR_USHORT( p, i, s ) ( (unsigned short)( ((const unsigned char *)(p))[(i)] ) << (s) )
@@ -442,23 +466,16 @@ pango_win32_dwrite_font_check_is_hinted (PangoWin32Font *font)
gboolean result = FALSE;
gboolean dwrite_font_release = FALSE;
- gboolean succeeded = FALSE;
- PangoWin32DWriteItems *dwrite_items = pango_win32_get_direct_write_items ();
- dwrite_font = (IDWriteFont *) g_hash_table_lookup (PANGO_WIN32_FONT_MAP (font->fontmap)->dwrite_fonts,
- &font->logfontw);
+ dwrite_font = get_dwrite_font_from_pango_win32_font (font, &dwrite_font_release);
- /* create the IDWriteFont from the logfont underlying the PangoWin32Font if needed */
if (dwrite_font == NULL)
{
- if (FAILED (dwrite_items->gdi_interop->CreateFontFromLOGFONT (&font->logfontw,
- &dwrite_font)) ||
- dwrite_font == NULL)
- failed = TRUE;
- else
- dwrite_font_release = TRUE;
+ g_warning ("Failed to retrieve IDWriteFont from PangoWin32Font");
+
+ return FALSE;
}
- if (!failed && SUCCEEDED (dwrite_font->CreateFontFace (&dwrite_font_face)) && dwrite_font_face != NULL)
+ if (SUCCEEDED (dwrite_font->CreateFontFace (&dwrite_font_face)) && dwrite_font_face != NULL)
{
UINT32 gasp_tag = DWRITE_MAKE_OPENTYPE_TAG ('g', 'a', 's', 'p');
UINT32 table_size;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]