[pango/pango2-windows: 4/5] pangodwrite-fontmap.cpp: Set up DirectWrite GDI interop




commit a4ed7a545f332822bd869a7ec509fa7cf8814ca3
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jul 4 11:43:14 2022 +0800

    pangodwrite-fontmap.cpp: Set up DirectWrite GDI interop
    
    This makes our DirectWrite fontmap object to set up GDI interop, since there
    are times when we still need to deal with GDI LOGFONTW objects, such as when we
    query the system fonts via SystemParametersInfoW() where the returned Windows
    font object is a LOGFONTW.

 pango2/pangodwrite-fontmap.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/pango2/pangodwrite-fontmap.cpp b/pango2/pangodwrite-fontmap.cpp
index 7f4ead157..6fa51c240 100644
--- a/pango2/pangodwrite-fontmap.cpp
+++ b/pango2/pangodwrite-fontmap.cpp
@@ -56,6 +56,7 @@ struct _Pango2DirectWriteFontMap
   Pango2FontMap parent_instance;
 
   IDWriteFactory *dwrite_factory;
+  IDWriteGdiInterop *gdi_interop;
 };
 
 struct _Pango2DirectWriteFontMapClass
@@ -352,6 +353,14 @@ pango2_direct_write_font_map_init (Pango2DirectWriteFontMap *self)
   if (FAILED (hr) || !self->dwrite_factory)
     g_error ("DWriteCreateFactory failed with error code %x", (unsigned)hr);
 
+  if (self->dwrite_factory)
+    {
+      hr = self->dwrite_factory->GetGdiInterop (&self->gdi_interop);
+
+      if (FAILED (hr) || !self->gdi_interop)
+        g_error ("GdiInterop failed with error code %x", (unsigned)hr);
+    }
+
   pango2_font_map_repopulate (PANGO2_FONT_MAP (self), TRUE);
 }
 
@@ -360,6 +369,12 @@ pango2_direct_write_font_map_finalize (GObject *object)
 {
   Pango2DirectWriteFontMap *dwrite_map = PANGO2_DIRECT_WRITE_FONT_MAP (object);
 
+  if (dwrite_map->gdi_interop != NULL)
+    {
+      dwrite_map->gdi_interop->Release ();
+      dwrite_map->gdi_interop = NULL;
+    }
+
   dwrite_map->dwrite_factory->Release ();
   dwrite_map->dwrite_factory = NULL;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]