<div dir="ltr">On Tue, Mar 10, 2015 at 12:17 PM, suzuki toshiya <span dir="ltr"><<a href="mailto:mpsuzuki@hiroshima-u.ac.jp" target="_blank">mpsuzuki@hiroshima-u.ac.jp</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
Here I propose a patch to restore the support of Mac OS X 10.4<br>
support, which detects the CTFont availability by configure,<br>
following to the design by Ryan Schmidt<br>
<a href="http://lists.cairographics.org/archives/cairo/2015-February/025959.html" target="_blank">http://lists.cairographics.org/archives/cairo/2015-February/025959.html</a><br>
<br>
I don't think the change is too complex to drop Mac OS X 10.4<br>
support... How do you think of?<br></blockquote><div><br></div><div>The change itself is not very complex, but maintaining 10.4 is becoming unfeasible, given that testing is very hard.<br></div><div>This is confirmed by the bug you have in your patch :P (see comment inline).<br><br></div><div>Instead of adding #ifdef's and configure-time detection (which is usually the wrong thing to do for mac, as you might be compiling with a newer SDK and targeting an old OSX version), the commit you're looking for should be something like <a href="http://cgit.freedesktop.org/~ranma42/cairo/commit/?h=wip/restore-10.4&id=c2d111ecbf729fe1ecdfcc260f2c51cd3e96fe37">http://cgit.freedesktop.org/~ranma42/cairo/commit/?h=wip/restore-10.4&id=c2d111ecbf729fe1ecdfcc260f2c51cd3e96fe37</a><br><br></div><div>Another option, which at least to me sounds very appealing, is to let 10.4 die (from Apple's point of view, it's unsupported since September 2009) and cleanup cairo-quartz as in <a href="http://cgit.freedesktop.org/~ranma42/cairo/commit/?h=wip/remove-10.4&id=66b5419704aa1971c77de764fd94b2f7d2a05b76">http://cgit.freedesktop.org/~ranma42/cairo/commit/?h=wip/remove-10.4&id=66b5419704aa1971c77de764fd94b2f7d2a05b76</a><br>This would remove most of the weirdness in the quartz backend (the two bigger culprits are currently blend modes and font metrics).<br><br></div><div>Of course, if the remove-10.4 branch was merged, the patch to restore 10.4 would be much more complex, so we could say that supporting 10.4 requires a significant complexity in cairo-quartz.</div><div><br></div><div>Andrea<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Regards,<br>
mpsuzuki<br>
<br>
<br>
Andrea Canciani wrote:<br>
> From: Andrea Canciani <ranma42@tartaros.local><br>
><br>
> Since 70cc8f250b5669e757b4f044571ba0f71e3dea9e the quartz backend is<br>
> using some APIs that are not available on MacOSX 10.4 directly<br>
> (i.e. without detecting their availability through dynamic linking).<br>
> This means that the quartz backend does not work anymore on MacOSX<br>
> 10.4 and that the 10.5 SDK (or newer) is needed to build.<br>
> ---<br>
>  README | 2 +-<br>
>  1 file changed, 1 insertion(+), 1 deletion(-)<br>
><br>
> diff --git a/README b/README<br>
> index 5926430..0be9947 100644<br>
> --- a/README<br>
> +++ b/README<br>
> @@ -121,7 +121,7 @@ Supported, "platform" surface backends<br>
><br>
>       quartz backend<br>
>       --------------<br>
> -     MacOS X >= 10.4 with Xcode >= 2.4<br>
> +     MacOS X >= 10.5 with Xcode >= 3.0<br>
><br>
>       win32 backend<br>
>       ------------- </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
index 2ce1959..23216c2 100644<br>
--- a/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
@@ -210,8 +210,43 @@ CAIRO_ENABLE_SURFACE_BACKEND(quartz, Quartz, auto, [<br>
<br>
 CAIRO_ENABLE_FONT_BACKEND(quartz_font, Quartz, auto, [<br>
   use_quartz_font=$use_quartz<br>
+  if test "x$use_quartz_font" = "xyes" ; then<br>
+    dnl include Quartz header to check CTFontRef declaration<br>
+    header_for_CTFontRef=""<br>
+    if test "x${ac_cv_header_ApplicationServices_ApplicationServices_h}" = "xyes" ; then<br>
+      header_for_CTFontRef=ApplicationServices/ApplicationServices.h<br>
+    else<br>
+      AC_CHECK_HEADER(CoreText/CoreText.h,[<br>
+        header_for_CTFontRef=CoreText/CoreText.h<br>
+      ],[])<br>
+    fi<br>
+<br>
+    if test "x${header_for_CTFontRef}" != "x" ; then<br>
+      AC_CHECK_TYPE(CTFontRef,[<br>
+          AC_DEFINE([QUARTZ_HAS_CTFONTREF_T], 1, [Define to 1 if CTFontRef type is defined in CTFont.h])<br>
+        ],[],[#include "${header_for_CTFontRef}"]<br>
+      )<br>
+    fi<br>
+  fi<br>
 ])<br>
<br>
+if test "x$use_quartz" = "xyes" ; then<br>
+  dnl include Quartz header to check CGDataProviderReleaseDataCallback declaration<br>
+  header_for_CGDataProviderReleaseDataCallback=""<br>
+  if test "x${ac_cv_header_ApplicationServices_ApplicationServices_h}" = "xyes" ; then<br>
+    header_for_CGDataProviderReleaseDataCallback=ApplicationServices/ApplicationServices.h<br>
+  elif test "x${ac_cv_header_CoreGraphics_CoreGraphics_h}" = "xyes" ; then<br>
+    header_for_CGDataProviderReleaseDataCallback=CoreGraphics/CoreGraphics.h<br>
+  fi<br>
+<br>
+  if test "x${header_for_CGDataProviderReleaseDataCallback}" != "x" ; then<br>
+    AC_CHECK_TYPE(CGDataProviderReleaseDataCallback,[<br>
+        AC_DEFINE([QUARTZ_HAS_CGDATAPROVIDERRELEASEDATACALLBACK_T], 1, [Define to 1 if CGDataProviderReleaseDataCallback type is defined in CGDataProvider.h])<br>
+      ],[],[#include "${header_for_CGDataProviderReleaseDataCallback}"]<br>
+    )<br>
+  fi<br>
+fi<br>
+<br>
 CAIRO_ENABLE_SURFACE_BACKEND(quartz_image, Quartz Image, no, [<br>
   use_quartz_image=$use_quartz<br>
 ])<br>
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c<br>
index 02f3426..35fe24d 100644<br>
--- a/src/cairo-quartz-font.c<br>
+++ b/src/cairo-quartz-font.c<br>
@@ -81,6 +81,18 @@ static void (*CGFontGetGlyphsForUnicharsPtr) (CGFontRef, const UniChar[], const<br>
 static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL;<br>
 static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;<br>
<br>
+/* Not public in the least bit */<br>
+static CGPathRef (*CGFontGetGlyphPathPtr) (CGFontRef fontRef, CGAffineTransform *textTransform, int unknown, CGGlyph glyph) = NULL;<br>
+<br>
+/* CoreText Replacement of CGFontGetGlyphPathPtr */<br>
+#ifdef QUARTZ_HAS_CTFONTREF_T </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">+static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef , CGFloat size, const CGAffineTransform*, CTFontDescriptorRef) = NULL; </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+static CGPathRef (*CTFontCreatePathForGlyphPtr) (CTFontRef, CGGlyph, CGAffineTransform *) = NULL;<br>
+#else<br>
+static void* CTFontCreateWithGraphicsFontPtr = NULL;<br>
+static void* CTFontCreatePathForGlyphPtr = NULL;<br>
+#endif<br>
+<br>
 /* CGFontGetHMetrics isn't public, but the other functions are public/present in 10.5 */<br>
 typedef struct {<br>
     int ascent;<br>
@@ -125,6 +137,13 @@ quartz_font_ensure_symbols(void)<br>
     CGFontGetUnitsPerEmPtr = dlsym(RTLD_DEFAULT, "CGFontGetUnitsPerEm");<br>
     CGFontGetGlyphAdvancesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphAdvances");<br>
<br>
+#ifdef QUARTZ_HAS_CTFONTREF_T<br>
+    CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT, "CTFontCreateWithGraphicsFont");<br>
+    CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT, "CTFontCreatePathForGlyphPtr");<br></blockquote><div><br></div><div>Hidden bug!<br>CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT, "CTFontCreatePathForGlyphPtr");<br><div>should be<br>CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT, "CTFontCreatePathForGlyph");<br></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+    if (!CTFontCreateWithGraphicsFontPtr || !CTFontCreatePathForGlyphPtr)<br>
+#endif<br>
+       CGFontGetGlyphPathPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphPath");<br>
+<br>
     CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics");<br>
     CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent");<br>
     CGFontGetDescentPtr = dlsym(RTLD_DEFAULT, "CGFontGetDescent");<br>
@@ -140,6 +159,7 @@ quartz_font_ensure_symbols(void)<br>
        CGFontGetGlyphsForUnicharsPtr &&<br>
        CGFontGetUnitsPerEmPtr &&<br>
        CGFontGetGlyphAdvancesPtr &&<br>
+       ((CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) || CGFontGetGlyphPathPtr) &&<br>
        (CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr)))<br>
        _cairo_quartz_font_symbols_present = TRUE;<br>
<br>
@@ -545,7 +565,6 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,<br>
     CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph);<br>
     CGAffineTransform textMatrix;<br>
     CGPathRef glyphPath;<br>
-    CTFontRef ctFont;<br>
     cairo_path_fixed_t *path;<br>
<br>
     if (glyph == INVALID_GLYPH) {<br>
@@ -560,9 +579,14 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,<br>
                                        -font->base.scale.yy,<br>
                                        0, 0);<br>
<br>
-    ctFont = CTFontCreateWithGraphicsFont (font_face->cgFont, 0.0, NULL, NULL);<br>
-    glyphPath = CTFontCreatePathForGlyph (ctFont, glyph, &textMatrix);<br>
-    CFRelease (ctFont);<br>
+#ifdef QUARTZ_HAS_CTFONTREF_T<br>
+    if (CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) {<br>
+        CTFontRef ctFont = CTFontCreateWithGraphicsFontPtr (font_face->cgFont, 0.0, NULL, NULL);<br>
+        glyphPath = CTFontCreatePathForGlyphPtr (ctFont, glyph, &textMatrix);<br>
+        CFRelease (ctFont);<br>
+    } else<br>
+#endif<br>
+       glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix, 0, glyph);<br>
     if (!glyphPath)<br>
        return CAIRO_INT_STATUS_UNSUPPORTED;<br>
<br>
<br></blockquote></div><br></div></div>