[cairo] [PATCH] Re: cairo-quartz-font.c: Non-public CGFontGetGlyphPath now deprecated

Simon Cozens simon at simon-cozens.org
Tue Jul 8 23:46:41 PDT 2014


On Thu, Jun 19, 2014 at 03:50:26PM +0900, Simon Cozens wrote:
> I am guessing that the official way to do things is to move to Core
> Text and CTFontCreatePathForGlyph. 

I've now done this, and it works...

diff --git a/configure.ac b/configure.ac
index 04479ff..f262dac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -200,7 +200,7 @@ CAIRO_ENABLE_SURFACE_BACKEND(quartz, Quartz, auto, [
   if test "x$use_quartz" != "xyes" ; then
     dnl check for CoreGraphics as a separate framework
     AC_CHECK_HEADER(CoreGraphics/CoreGraphics.h, , [use_quartz="no (requires CoreGraphics framework)"])
-    quartz_LIBS="-Xlinker -framework -Xlinker CoreGraphics"
+    quartz_LIBS="-Xlinker -framework -Xlinker CoreGraphics -framework -Xlinker CoreText"
   else
     quartz_LIBS="-Xlinker -framework -Xlinker ApplicationServices"
   fi
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index e6a379a..4518421 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -81,8 +81,8 @@ static void (*CGFontGetGlyphsForUnicharsPtr) (CGFontRef, const UniChar[], const
 static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL;
 static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
 
-/* Not public in the least bit */
-static CGPathRef (*CGFontGetGlyphPathPtr) (CGFontRef fontRef, CGAffineTransform *textTransform, int unknown, CGGlyph glyph) = NULL;
+static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef fontRef) = NULL;
+static CGPathRef (*CTFontCreatePathForGlyphPtr) (CTFontRef fontRef, CGGlyph glyph, CGAffineTransform *textTransform) = NULL;
 
 /* CGFontGetHMetrics isn't public, but the other functions are public/present in 10.5 */
 typedef struct {
@@ -127,7 +127,8 @@ quartz_font_ensure_symbols(void)
     /* These have the same name in 10.4 and 10.5 */
     CGFontGetUnitsPerEmPtr = dlsym(RTLD_DEFAULT, "CGFontGetUnitsPerEm");
     CGFontGetGlyphAdvancesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphAdvances");
-    CGFontGetGlyphPathPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphPath");
+    CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT, "CTFontCreatePathForGlyph");
+    CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT, "CTFontCreateWithGraphicsFont");
 
     CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics");
     CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent");
@@ -144,7 +145,8 @@ quartz_font_ensure_symbols(void)
    CGFontGetGlyphsForUnicharsPtr &&
    CGFontGetUnitsPerEmPtr &&
    CGFontGetGlyphAdvancesPtr &&
-   CGFontGetGlyphPathPtr &&
+   CTFontCreateWithGraphicsFontPtr &&
+   CTFontCreatePathForGlyphPtr &&
    (CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr)))
    _cairo_quartz_font_symbols_present = TRUE;
 
@@ -550,6 +552,7 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,
     CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph);
     CGAffineTransform textMatrix;
     CGPathRef glyphPath;
+    CTFontRef ctFont;
     cairo_path_fixed_t *path;
 
     if (glyph == INVALID_GLYPH) {
@@ -564,7 +567,8 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,
                    -font->base.scale.yy,
                    0, 0);
 
-    glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix, 0, glyph);
+    ctFont = CTFontCreateWithGraphicsFontPtr (font_face->cgFont);
+    glyphPath = CTFontCreatePathForGlyphPtr (ctFont, glyph, &textMatrix);
     if (!glyphPath)
    return CAIRO_INT_STATUS_UNSUPPORTED;
 


More information about the cairo mailing list