[pango/pango2: 278/301] coretext: Make cairo support work




commit 4dc0fa409c896ac6a4073b2ce1e4eec51f19a245
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 19 07:03:22 2022 -0700

    coretext: Make cairo support work

 pango/pangocairo-font.c | 39 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 1fc629fb0..d2d715c36 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -35,6 +35,14 @@
 #include "pango-userface-private.h"
 #include "pango-font-private.h"
 
+#if defined (HAVE_CORE_TEXT)
+
+#include <Carbon/Carbon.h>
+#include <cairo-quartz.h>
+#include <hb-coretext.h>
+
+#else
+
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wundef"
 #include <cairo-ft.h>
@@ -43,6 +51,8 @@
 #include <hb-ft.h>
 #include <freetype/ftmm.h>
 
+#endif
+
 #define PANGO_CAIRO_FONT_PRIVATE(font)         \
   ((PangoCairoFontPrivate *)                   \
    (font == NULL ? NULL :                      \
@@ -77,8 +87,6 @@ _pango_cairo_font_private_scaled_font_data_destroy (PangoCairoFontPrivateScaledF
     }
 }
 
-static FT_Library ft_library;
-
 static cairo_user_data_key_t cairo_user_data;
 
 static cairo_status_t
@@ -147,6 +155,31 @@ create_font_face_for_user_font (PangoFont *font)
   return cairo_face;
 }
 
+#if defined (HAVE_CORE_TEXT)
+
+static cairo_font_face_t *
+create_font_face_for_hb_font (PangoFont *font)
+{
+  hb_font_t *hbfont;
+  CTFontRef ctfont;
+  CGFontRef cgfont;
+  cairo_font_face_t *cairo_face;
+
+  hbfont = pango_font_get_hb_font (font);
+  ctfont = hb_coretext_font_get_ct_font (hbfont);
+  cgfont = CTFontCopyGraphicsFont (ctfont, NULL);
+
+  cairo_face = cairo_quartz_font_face_create_for_cgfont (cgfont);
+
+  CFRelease (cgfont);
+
+  return cairo_face;
+}
+
+#else
+
+static FT_Library ft_library;
+
 static cairo_font_face_t *
 create_font_face_for_hb_font (PangoFont *font)
 {
@@ -201,6 +234,8 @@ create_font_face_for_hb_font (PangoFont *font)
   return cairo_face;
 }
 
+#endif
+
 static cairo_scaled_font_t *
 _pango_cairo_font_private_get_scaled_font (PangoCairoFontPrivate *cf_priv)
 {


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