Skip to content

Instantly share code, notes, and snippets.

@zwaldowski
Created February 4, 2012 21:32
Show Gist options
  • Save zwaldowski/1740268 to your computer and use it in GitHub Desktop.
Save zwaldowski/1740268 to your computer and use it in GitHub Desktop.
Compile Cairo 1.10.2 universal on Lion
diff --git a/src/cairo-quartz.h b/src/cairo-quartz.h
index 8d001c5..bb41477 100644
--- a/src/cairo-quartz.h.old
+++ b/src/cairo-quartz.h
@@ -66,10 +66,8 @@ cairo_quartz_surface_get_cg_context (cairo_surface_t *surface);
cairo_public cairo_font_face_t *
cairo_quartz_font_face_create_for_cgfont (CGFontRef font);
-#ifndef __LP64__
cairo_public cairo_font_face_t *
cairo_quartz_font_face_create_for_atsu_font_id (ATSUFontID font_id);
-#endif
#endif /* CAIRO_HAS_QUARTZ_FONT */
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c
index 2c7e017..a18dc7d 100644
--- a/src/cairo-quartz-font.c.old
+++ b/src/cairo-quartz-font.c
@@ -89,6 +89,7 @@ static quartz_CGFontMetrics* (*CGFontGetHMetricsPtr) (CGFontRef fontRef) = NULL;
static int (*CGFontGetAscentPtr) (CGFontRef fontRef) = NULL;
static int (*CGFontGetDescentPtr) (CGFontRef fontRef) = NULL;
static int (*CGFontGetLeadingPtr) (CGFontRef fontRef) = NULL;
+static ATSFontRef (*FMGetATSFontRefFromFontPtr) (FMFont iFont) = NULL;
static cairo_bool_t _cairo_quartz_font_symbol_lookup_done = FALSE;
static cairo_bool_t _cairo_quartz_font_symbols_present = FALSE;
@@ -126,6 +127,7 @@ quartz_font_ensure_symbols(void)
CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing");
+ FMGetATSFontRefFromFontPtr = dlsym(RTLD_DEFAULT, "FMGetATSFontRefFromFont");
if ((CGFontCreateWithFontNamePtr || CGFontCreateWithNamePtr) &&
CGFontGetGlyphBBoxesPtr &&
@@ -777,7 +779,6 @@ _cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *abstract_font)
return ffont->cgFont;
}
-#ifndef __LP64__
/*
* compat with old ATSUI backend
*/
@@ -798,15 +799,19 @@ _cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *abstract_font)
cairo_font_face_t *
cairo_quartz_font_face_create_for_atsu_font_id (ATSUFontID font_id)
{
- ATSFontRef atsFont = FMGetATSFontRefFromFont (font_id);
- CGFontRef cgFont = CGFontCreateWithPlatformFont (&atsFont);
- cairo_font_face_t *ff;
-
- ff = cairo_quartz_font_face_create_for_cgfont (cgFont);
-
- CGFontRelease (cgFont);
+ quartz_font_ensure_symbols();
- return ff;
+ if (FMGetATSFontRefFromFontPtr != NULL) {
+ ATSFontRef atsFont = FMGetATSFontRefFromFontPtr (font_id);
+ CGFontRef cgFont = CGFontCreateWithPlatformFont (&atsFont);
+ cairo_font_face_t *ff;
+ ff = cairo_quartz_font_face_create_for_cgfont (cgFont);
+ CGFontRelease (cgFont);
+ return ff;
+ } else {
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+ return (cairo_font_face_t *)&_cairo_font_face_nil;
+ }
}
/* This is the old name for the above function, exported for compat purposes */
@@ -817,4 +822,3 @@ cairo_atsui_font_face_create_for_atsu_font_id (ATSUFontID font_id)
{
return cairo_quartz_font_face_create_for_atsu_font_id (font_id);
}
-#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment