<div dir="ltr">On Wed, Jul 9, 2014 at 8:46 AM, Simon Cozens <span dir="ltr"><<a href="mailto:simon@simon-cozens.org" target="_blank">simon@simon-cozens.org</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"><div class="">On Thu, Jun 19, 2014 at 03:50:26PM +0900, Simon Cozens wrote:<br>
> I am guessing that the official way to do things is to move to Core<br>
> Text and CTFontCreatePathForGlyph.<br>
<br>
</div>I've now done this, and it works...<br>
<br>
diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
index 04479ff..f262dac 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>
@@ -200,7 +200,7 @@ CAIRO_ENABLE_SURFACE_BACKEND(quartz, Quartz, auto, [<br>
if test "x$use_quartz" != "xyes" ; then<br>
dnl check for CoreGraphics as a separate framework<br>
AC_CHECK_HEADER(CoreGraphics/CoreGraphics.h, , [use_quartz="no (requires CoreGraphics framework)"])<br>
- quartz_LIBS="-Xlinker -framework -Xlinker CoreGraphics"<br>
+ quartz_LIBS="-Xlinker -framework -Xlinker CoreGraphics -framework -Xlinker CoreText"<br></blockquote><div><br><div>Is this also going to work on 10.4?<br></div><div>IIRC the CoreText API has been introduced in 10.5, so we should avoid linking it.<br>
</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">
else<br>
quartz_LIBS="-Xlinker -framework -Xlinker ApplicationServices"<br>
fi<br>
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c<br>
index e6a379a..4518421 100644<br>
--- a/src/cairo-quartz-font.c<br>
+++ b/src/cairo-quartz-font.c<br>
@@ -81,8 +81,8 @@ 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>
+static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef fontRef) = NULL;<br>
+static CGPathRef (*CTFontCreatePathForGlyphPtr) (CTFontRef fontRef, CGGlyph glyph, CGAffineTransform *textTransform) = NULL;<br>
<br>
/* CGFontGetHMetrics isn't public, but the other functions are public/present in 10.5 */<br>
typedef struct {<br>
@@ -127,7 +127,8 @@ quartz_font_ensure_symbols(void)<br>
/* These have the same name in 10.4 and 10.5 */<br>
CGFontGetUnitsPerEmPtr = dlsym(RTLD_DEFAULT, "CGFontGetUnitsPerEm");<br>
CGFontGetGlyphAdvancesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphAdvances");<br>
- CGFontGetGlyphPathPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphPath");<br>
+ CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT, "CTFontCreatePathForGlyph");<br>
+ CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT, "CTFontCreateWithGraphicsFont");<br>
<br>
CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics");<br>
CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent");<br>
@@ -144,7 +145,8 @@ quartz_font_ensure_symbols(void)<br>
CGFontGetGlyphsForUnicharsPtr &&<br>
CGFontGetUnitsPerEmPtr &&<br>
CGFontGetGlyphAdvancesPtr &&<br>
- CGFontGetGlyphPathPtr &&<br>
+ CTFontCreateWithGraphicsFontPtr &&<br>
+ CTFontCreatePathForGlyphPtr &&<br></blockquote><div><br><div>An alternative which should also work on 10.4 looks like this:<br></div>(CGFontGetGlyphPathPtr || (CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr)) &&<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
(CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr)))<br>
_cairo_quartz_font_symbols_present = TRUE;<br>
<br>
@@ -550,6 +552,7 @@ _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>
@@ -564,7 +567,8 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,<br>
-font->base.scale.yy,<br>
0, 0);<br>
<br>
- glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix, 0, glyph);<br>
+ ctFont = CTFontCreateWithGraphicsFontPtr (font_face->cgFont);<br>
+ glyphPath = CTFontCreatePathForGlyphPtr (ctFont, glyph, &textMatrix);<br></blockquote><div><br></div><div>Assuming the new check in the ensure function, you could do:<br>if (CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) {<br>
CTFontRef ctFont = CTFontCreateWithGraphicsFontPtr (font_face->cgFont);<br><div id=":1pz" class=""> glyphPath = CTFontCreatePathForGlyphPtr (ctFont, glyph, &textMatrix);<br> CFRelease(ctFont);<br></div><div id=":1pz" class="">
} else {<br> glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix, 0, glyph);<br>}<br></div>
</div><div><br></div><div>I added CFRelease() because all of the examples of use of CTFont seem to release it in this way.<br>Unfortunately right now I am unable to test the code, hence do not trust it.<br></div><div>Given that the minimum requirements for Firefox are now of MacOS X 10.6, it might also be time to revisit the versions supported by Cairo.<br>
</div><div>This would also make it possible to get rid of most of the dynamic function discovery mechanism, as only CGContextGetType and CGContextGetAllowsFontSmoothing are not public in 10.6.<br><br>Jeff, Chris, what do you think about this?<br>
</div><div>I am afraid that testing on 10.4 will become increasingly difficult over time (I would guess that even Mozilla is not testing anymore on it, as they're not supporting it anymore).<br></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">
if (!glyphPath)<br>
return CAIRO_INT_STATUS_UNSUPPORTED;<br>
<div class=""><div class="h5"><br>
--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</div></div></blockquote></div><br></div></div>