summaryrefslogtreecommitdiff
path: root/src/cairo-quartz-font.c
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2017-01-18 13:08:11 +0100
committerAndrea Canciani <ranma42@gmail.com>2017-01-18 15:06:33 +0100
commit5a8a9c97ed268004cbac510d39739ff56c0fb43c (patch)
tree13deb6b112e683d82afc1189b1b63203b5a0f64f /src/cairo-quartz-font.c
parentdd4706d0a9d123d3aa4284ac9ab35fbe165278b2 (diff)
downloadcairo-5a8a9c97ed268004cbac510d39739ff56c0fb43c.tar.gz
quartz: Restore 10.4-specific font code
The code for extracting font glyphs was replaced in 70cc8f250b5669e757b4f044571ba0f71e3dea9e with an implementation based on CoreText, which is not available on MacOSX 10.4. This commit restores automatic detection of which API should be used by means of dynamic linking.
Diffstat (limited to 'src/cairo-quartz-font.c')
-rw-r--r--src/cairo-quartz-font.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index feee61a0d..897b2d01a 100644
--- a/src/cairo-quartz-font.c
+++ b/src/cairo-quartz-font.c
@@ -81,6 +81,14 @@ 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;
+
+/* CTFontCreateWithGraphicsFont is not available until 10.5 */
+typedef const struct __CTFontDescriptor *CTFontDescriptorRef;
+static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef, CGFloat, const CGAffineTransform*, CTFontDescriptorRef) = NULL;
+static CGPathRef (*CTFontCreatePathForGlyphPtr) (CTFontRef, CGGlyph, CGAffineTransform *) = NULL;
+
/* CGFontGetHMetrics isn't public, but the other functions are public/present in 10.5 */
typedef struct {
int ascent;
@@ -125,6 +133,11 @@ quartz_font_ensure_symbols(void)
CGFontGetUnitsPerEmPtr = dlsym(RTLD_DEFAULT, "CGFontGetUnitsPerEm");
CGFontGetGlyphAdvancesPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphAdvances");
+ CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT, "CTFontCreateWithGraphicsFont");
+ CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT, "CTFontCreatePathForGlyph");
+ if (!CTFontCreateWithGraphicsFontPtr || !CTFontCreatePathForGlyphPtr)
+ CGFontGetGlyphPathPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphPath");
+
CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics");
CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent");
CGFontGetDescentPtr = dlsym(RTLD_DEFAULT, "CGFontGetDescent");
@@ -140,6 +153,7 @@ quartz_font_ensure_symbols(void)
CGFontGetGlyphsForUnicharsPtr &&
CGFontGetUnitsPerEmPtr &&
CGFontGetGlyphAdvancesPtr &&
+ ((CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) || CGFontGetGlyphPathPtr) &&
(CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr)))
_cairo_quartz_font_symbols_present = TRUE;
@@ -545,7 +559,6 @@ _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) {
@@ -560,9 +573,14 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,
-font->base.scale.yy,
0, 0);
- ctFont = CTFontCreateWithGraphicsFont (font_face->cgFont, 1.0, NULL, NULL);
- glyphPath = CTFontCreatePathForGlyph (ctFont, glyph, &textMatrix);
- CFRelease (ctFont);
+ if (CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) {
+ CTFontRef ctFont = CTFontCreateWithGraphicsFontPtr (font_face->cgFont, 1.0, NULL, NULL);
+ glyphPath = CTFontCreatePathForGlyphPtr (ctFont, glyph, &textMatrix);
+ CFRelease (ctFont);
+ } else {
+ glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix, 0, glyph);
+ }
+
if (!glyphPath)
return CAIRO_INT_STATUS_UNSUPPORTED;