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




commit 3273fe0292b9269eede8379779a6bbed9b57d17b
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 sets up our DirectWrite fontmap object to use GDI interop when requested,
    so to help people transition easier to Pango2+Cairo on Windows.

 pango2/pangodwrite-fontmap.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/pango2/pangodwrite-fontmap.cpp b/pango2/pangodwrite-fontmap.cpp
index 4a13ef822..e9f105c71 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;
   gboolean use_gdi;
 };
 
@@ -360,6 +361,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);
 }
 
@@ -368,6 +377,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]