gfx/cairo/quartz-support-color-emoji-font.patch

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 From: Jonathan Kew <jkew@mozilla.com>
michael@0 2 bug 715798 pt 1 - support Apple Color Emoji font in cairo-quartz backend. r=jrmuizel
michael@0 3
michael@0 4 diff --git a/gfx/cairo/cairo/src/cairo-quartz-font.c b/gfx/cairo/cairo/src/cairo-quartz-font.c
michael@0 5 --- a/gfx/cairo/cairo/src/cairo-quartz-font.c
michael@0 6 +++ b/gfx/cairo/cairo/src/cairo-quartz-font.c
michael@0 7 @@ -85,16 +85,20 @@ typedef struct {
michael@0 8 int descent;
michael@0 9 int leading;
michael@0 10 } quartz_CGFontMetrics;
michael@0 11 static quartz_CGFontMetrics* (*CGFontGetHMetricsPtr) (CGFontRef fontRef) = NULL;
michael@0 12 static int (*CGFontGetAscentPtr) (CGFontRef fontRef) = NULL;
michael@0 13 static int (*CGFontGetDescentPtr) (CGFontRef fontRef) = NULL;
michael@0 14 static int (*CGFontGetLeadingPtr) (CGFontRef fontRef) = NULL;
michael@0 15
michael@0 16 +/* CTFontCreateWithGraphicsFont is not public until 10.5. */
michael@0 17 +typedef const struct __CTFontDescriptor *CTFontDescriptorRef;
michael@0 18 +static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef, CGFloat, const CGAffineTransform *, CTFontDescriptorRef) = NULL;
michael@0 19 +
michael@0 20 static cairo_bool_t _cairo_quartz_font_symbol_lookup_done = FALSE;
michael@0 21 static cairo_bool_t _cairo_quartz_font_symbols_present = FALSE;
michael@0 22
michael@0 23 static void
michael@0 24 quartz_font_ensure_symbols(void)
michael@0 25 {
michael@0 26 if (_cairo_quartz_font_symbol_lookup_done)
michael@0 27 return;
michael@0 28 @@ -122,16 +126,18 @@ quartz_font_ensure_symbols(void)
michael@0 29 CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics");
michael@0 30 CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent");
michael@0 31 CGFontGetDescentPtr = dlsym(RTLD_DEFAULT, "CGFontGetDescent");
michael@0 32 CGFontGetLeadingPtr = dlsym(RTLD_DEFAULT, "CGFontGetLeading");
michael@0 33
michael@0 34 CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
michael@0 35 CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing");
michael@0 36
michael@0 37 + CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT, "CTFontCreateWithGraphicsFont");
michael@0 38 +
michael@0 39 if ((CGFontCreateWithFontNamePtr || CGFontCreateWithNamePtr) &&
michael@0 40 CGFontGetGlyphBBoxesPtr &&
michael@0 41 CGFontGetGlyphsForUnicharsPtr &&
michael@0 42 CGFontGetUnitsPerEmPtr &&
michael@0 43 CGFontGetGlyphAdvancesPtr &&
michael@0 44 CGFontGetGlyphPathPtr &&
michael@0 45 (CGFontGetHMetricsPtr || (CGFontGetAscentPtr && CGFontGetDescentPtr && CGFontGetLeadingPtr)))
michael@0 46 _cairo_quartz_font_symbols_present = TRUE;
michael@0 47 @@ -145,16 +151,17 @@ typedef struct _cairo_quartz_scaled_font
michael@0 48 struct _cairo_quartz_scaled_font {
michael@0 49 cairo_scaled_font_t base;
michael@0 50 };
michael@0 51
michael@0 52 struct _cairo_quartz_font_face {
michael@0 53 cairo_font_face_t base;
michael@0 54
michael@0 55 CGFontRef cgFont;
michael@0 56 + CTFontRef ctFont;
michael@0 57 };
michael@0 58
michael@0 59 /*
michael@0 60 * font face backend
michael@0 61 */
michael@0 62
michael@0 63 static cairo_status_t
michael@0 64 _cairo_quartz_font_face_create_for_toy (cairo_toy_font_face_t *toy_face,
michael@0 65 @@ -229,16 +236,20 @@ static cairo_status_t
michael@0 66 return CAIRO_STATUS_SUCCESS;
michael@0 67 }
michael@0 68
michael@0 69 static void
michael@0 70 _cairo_quartz_font_face_destroy (void *abstract_face)
michael@0 71 {
michael@0 72 cairo_quartz_font_face_t *font_face = (cairo_quartz_font_face_t*) abstract_face;
michael@0 73
michael@0 74 + if (font_face->ctFont) {
michael@0 75 + CFRelease (font_face->ctFont);
michael@0 76 + }
michael@0 77 +
michael@0 78 CGFontRelease (font_face->cgFont);
michael@0 79 }
michael@0 80
michael@0 81 static const cairo_scaled_font_backend_t _cairo_quartz_scaled_font_backend;
michael@0 82
michael@0 83 static cairo_status_t
michael@0 84 _cairo_quartz_font_face_scaled_font_create (void *abstract_face,
michael@0 85 const cairo_matrix_t *font_matrix,
michael@0 86 @@ -353,16 +364,22 @@ cairo_quartz_font_face_create_for_cgfont
michael@0 87 if (!font_face) {
michael@0 88 cairo_status_t ignore_status;
michael@0 89 ignore_status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
michael@0 90 return (cairo_font_face_t *)&_cairo_font_face_nil;
michael@0 91 }
michael@0 92
michael@0 93 font_face->cgFont = CGFontRetain (font);
michael@0 94
michael@0 95 + if (CTFontCreateWithGraphicsFontPtr) {
michael@0 96 + font_face->ctFont = CTFontCreateWithGraphicsFontPtr (font, 1.0, NULL, NULL);
michael@0 97 + } else {
michael@0 98 + font_face->ctFont = NULL;
michael@0 99 + }
michael@0 100 +
michael@0 101 _cairo_font_face_init (&font_face->base, &_cairo_quartz_font_face_backend);
michael@0 102
michael@0 103 return &font_face->base;
michael@0 104 }
michael@0 105
michael@0 106 /*
michael@0 107 * scaled font backend
michael@0 108 */
michael@0 109 @@ -772,16 +789,24 @@ static const cairo_scaled_font_backend_t
michael@0 110 CGFontRef
michael@0 111 _cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *abstract_font)
michael@0 112 {
michael@0 113 cairo_quartz_font_face_t *ffont = _cairo_quartz_scaled_to_face(abstract_font);
michael@0 114
michael@0 115 return ffont->cgFont;
michael@0 116 }
michael@0 117
michael@0 118 +CTFontRef
michael@0 119 +_cairo_quartz_scaled_font_get_ct_font_ref (cairo_scaled_font_t *abstract_font)
michael@0 120 +{
michael@0 121 + cairo_quartz_font_face_t *ffont = _cairo_quartz_scaled_to_face(abstract_font);
michael@0 122 +
michael@0 123 + return ffont->ctFont;
michael@0 124 +}
michael@0 125 +
michael@0 126 #ifndef __LP64__
michael@0 127 /*
michael@0 128 * compat with old ATSUI backend
michael@0 129 */
michael@0 130
michael@0 131 /**
michael@0 132 * cairo_quartz_font_face_create_for_atsu_font_id
michael@0 133 * @font_id: an ATSUFontID for the font.
michael@0 134 diff --git a/gfx/cairo/cairo/src/cairo-quartz-private.h b/gfx/cairo/cairo/src/cairo-quartz-private.h
michael@0 135 --- a/gfx/cairo/cairo/src/cairo-quartz-private.h
michael@0 136 +++ b/gfx/cairo/cairo/src/cairo-quartz-private.h
michael@0 137 @@ -45,16 +45,19 @@
michael@0 138 #include "cairo-surface-clipper-private.h"
michael@0 139
michael@0 140 #ifdef CGFLOAT_DEFINED
michael@0 141 typedef CGFloat cairo_quartz_float_t;
michael@0 142 #else
michael@0 143 typedef float cairo_quartz_float_t;
michael@0 144 #endif
michael@0 145
michael@0 146 +/* define CTFontRef for pre-10.5 SDKs */
michael@0 147 +typedef const struct __CTFont *CTFontRef;
michael@0 148 +
michael@0 149 typedef struct cairo_quartz_surface {
michael@0 150 cairo_surface_t base;
michael@0 151
michael@0 152 CGContextRef cgContext;
michael@0 153 CGAffineTransform cgContextBaseCTM;
michael@0 154
michael@0 155 void *imageData;
michael@0 156 cairo_surface_t *imageSurfaceEquiv;
michael@0 157 @@ -99,15 +102,18 @@ CGImageRef
michael@0 158 cairo_bool_t interpolate,
michael@0 159 CGColorSpaceRef colorSpaceOverride,
michael@0 160 CGDataProviderReleaseDataCallback releaseCallback,
michael@0 161 void *releaseInfo);
michael@0 162
michael@0 163 CGFontRef
michael@0 164 _cairo_quartz_scaled_font_get_cg_font_ref (cairo_scaled_font_t *sfont);
michael@0 165
michael@0 166 +CTFontRef
michael@0 167 +_cairo_quartz_scaled_font_get_ct_font_ref (cairo_scaled_font_t *sfont);
michael@0 168 +
michael@0 169 #else
michael@0 170
michael@0 171 # error Cairo was not compiled with support for the quartz backend
michael@0 172
michael@0 173 #endif /* CAIRO_HAS_QUARTZ_SURFACE */
michael@0 174
michael@0 175 #endif /* CAIRO_QUARTZ_PRIVATE_H */
michael@0 176 diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
michael@0 177 --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
michael@0 178 +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
michael@0 179 @@ -130,16 +130,19 @@ static void (*CGContextClipToMaskPtr) (C
michael@0 180 static void (*CGContextDrawTiledImagePtr) (CGContextRef, CGRect, CGImageRef) = NULL;
michael@0 181 static unsigned int (*CGContextGetTypePtr) (CGContextRef) = NULL;
michael@0 182 static void (*CGContextSetShouldAntialiasFontsPtr) (CGContextRef, bool) = NULL;
michael@0 183 static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) = NULL;
michael@0 184 static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;
michael@0 185 static CGPathRef (*CGContextCopyPathPtr) (CGContextRef) = NULL;
michael@0 186 static CGFloat (*CGContextGetAlphaPtr) (CGContextRef) = NULL;
michael@0 187
michael@0 188 +/* CTFontDrawGlyphs is not available until 10.7 */
michael@0 189 +static void (*CTFontDrawGlyphsPtr) (CTFontRef, const CGGlyph[], const CGPoint[], size_t, CGContextRef) = NULL;
michael@0 190 +
michael@0 191 static SInt32 _cairo_quartz_osx_version = 0x0;
michael@0 192
michael@0 193 static cairo_bool_t _cairo_quartz_symbol_lookup_done = FALSE;
michael@0 194
michael@0 195 /*
michael@0 196 * Utility functions
michael@0 197 */
michael@0 198
michael@0 199 @@ -167,16 +170,18 @@ static void quartz_ensure_symbols(void)
michael@0 200 CGContextDrawTiledImagePtr = dlsym(RTLD_DEFAULT, "CGContextDrawTiledImage");
michael@0 201 CGContextGetTypePtr = dlsym(RTLD_DEFAULT, "CGContextGetType");
michael@0 202 CGContextSetShouldAntialiasFontsPtr = dlsym(RTLD_DEFAULT, "CGContextSetShouldAntialiasFonts");
michael@0 203 CGContextCopyPathPtr = dlsym(RTLD_DEFAULT, "CGContextCopyPath");
michael@0 204 CGContextGetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextGetAllowsFontSmoothing");
michael@0 205 CGContextSetAllowsFontSmoothingPtr = dlsym(RTLD_DEFAULT, "CGContextSetAllowsFontSmoothing");
michael@0 206 CGContextGetAlphaPtr = dlsym(RTLD_DEFAULT, "CGContextGetAlpha");
michael@0 207
michael@0 208 + CTFontDrawGlyphsPtr = dlsym(RTLD_DEFAULT, "CTFontDrawGlyphs");
michael@0 209 +
michael@0 210 if (Gestalt(gestaltSystemVersion, &_cairo_quartz_osx_version) != noErr) {
michael@0 211 // assume 10.5
michael@0 212 _cairo_quartz_osx_version = 0x1050;
michael@0 213 }
michael@0 214
michael@0 215 _cairo_quartz_symbol_lookup_done = TRUE;
michael@0 216 }
michael@0 217
michael@0 218 @@ -605,20 +610,23 @@ static inline void
michael@0 219 dst->d = src->yy;
michael@0 220 dst->tx = src->x0;
michael@0 221 dst->ty = src->y0;
michael@0 222 }
michael@0 223
michael@0 224 typedef struct {
michael@0 225 bool isClipping;
michael@0 226 CGGlyph *cg_glyphs;
michael@0 227 - CGSize *cg_advances;
michael@0 228 + union {
michael@0 229 + CGSize *cg_advances;
michael@0 230 + CGPoint *cg_positions;
michael@0 231 + } u;
michael@0 232 size_t nglyphs;
michael@0 233 CGAffineTransform textTransform;
michael@0 234 - CGFontRef font;
michael@0 235 + cairo_scaled_font_t *scaled_font;
michael@0 236 CGPoint origin;
michael@0 237 } unbounded_show_glyphs_t;
michael@0 238
michael@0 239 typedef struct {
michael@0 240 CGPathRef cgPath;
michael@0 241 cairo_fill_rule_t fill_rule;
michael@0 242 } unbounded_stroke_fill_t;
michael@0 243
michael@0 244 @@ -686,36 +694,43 @@ static void
michael@0 245 CGContextBeginPath (cgc);
michael@0 246 CGContextAddPath (cgc, op->u.stroke_fill.cgPath);
michael@0 247
michael@0 248 if (op->u.stroke_fill.fill_rule == CAIRO_FILL_RULE_WINDING)
michael@0 249 CGContextFillPath (cgc);
michael@0 250 else
michael@0 251 CGContextEOFillPath (cgc);
michael@0 252 } else if (op->op == UNBOUNDED_SHOW_GLYPHS) {
michael@0 253 - CGContextSetFont (cgc, op->u.show_glyphs.font);
michael@0 254 - CGContextSetFontSize (cgc, 1.0);
michael@0 255 - CGContextSetTextMatrix (cgc, CGAffineTransformIdentity);
michael@0 256 - CGContextTranslateCTM (cgc, op->u.show_glyphs.origin.x, op->u.show_glyphs.origin.y);
michael@0 257 - CGContextConcatCTM (cgc, op->u.show_glyphs.textTransform);
michael@0 258 -
michael@0 259 if (op->u.show_glyphs.isClipping) {
michael@0 260 /* Note that the comment in show_glyphs about kCGTextClip
michael@0 261 * and the text transform still applies here; however, the
michael@0 262 * cg_advances we have were already transformed, so we
michael@0 263 * don't have to do anything. */
michael@0 264 CGContextSetTextDrawingMode (cgc, kCGTextClip);
michael@0 265 CGContextSaveGState (cgc);
michael@0 266 }
michael@0 267 -
michael@0 268 - CGContextShowGlyphsWithAdvances (cgc,
michael@0 269 - op->u.show_glyphs.cg_glyphs,
michael@0 270 - op->u.show_glyphs.cg_advances,
michael@0 271 - op->u.show_glyphs.nglyphs);
michael@0 272 -
michael@0 273 + CGContextTranslateCTM (cgc, op->u.show_glyphs.origin.x, op->u.show_glyphs.origin.y);
michael@0 274 + CGContextConcatCTM (cgc, op->u.show_glyphs.textTransform);
michael@0 275 + if (CTFontDrawGlyphsPtr) {
michael@0 276 + CTFontDrawGlyphsPtr (_cairo_quartz_scaled_font_get_ct_font_ref (op->u.show_glyphs.scaled_font),
michael@0 277 + op->u.show_glyphs.cg_glyphs,
michael@0 278 + op->u.show_glyphs.u.cg_positions,
michael@0 279 + op->u.show_glyphs.nglyphs,
michael@0 280 + cgc);
michael@0 281 + } else {
michael@0 282 + CGContextSetFont (cgc, _cairo_quartz_scaled_font_get_cg_font_ref (op->u.show_glyphs.scaled_font));
michael@0 283 + CGContextSetFontSize (cgc, 1.0);
michael@0 284 + CGContextSetTextMatrix (cgc, CGAffineTransformIdentity);
michael@0 285 +
michael@0 286 + CGContextShowGlyphsWithAdvances (cgc,
michael@0 287 + op->u.show_glyphs.cg_glyphs,
michael@0 288 + op->u.show_glyphs.u.cg_advances,
michael@0 289 + op->u.show_glyphs.nglyphs);
michael@0 290 +
michael@0 291 + }
michael@0 292 if (op->u.show_glyphs.isClipping) {
michael@0 293 CGContextClearRect (cgc, clipBoxRound);
michael@0 294 CGContextRestoreGState (cgc);
michael@0 295 }
michael@0 296 } else if (op->op == UNBOUNDED_MASK) {
michael@0 297 CGAffineTransform ctm = CGContextGetCTM (cgc);
michael@0 298 CGContextSaveGState (cgc);
michael@0 299 CGContextConcatCTM (cgc, op->u.mask.maskTransform);
michael@0 300 @@ -2684,16 +2699,19 @@ static cairo_int_status_t
michael@0 301 cairo_clip_t *clip,
michael@0 302 int *remaining_glyphs)
michael@0 303 {
michael@0 304 CGAffineTransform textTransform, ctm, invTextTransform;
michael@0 305 #define STATIC_BUF_SIZE 64
michael@0 306 CGGlyph glyphs_static[STATIC_BUF_SIZE];
michael@0 307 CGSize cg_advances_static[STATIC_BUF_SIZE];
michael@0 308 CGGlyph *cg_glyphs = &glyphs_static[0];
michael@0 309 + /* We'll use the cg_advances array for either advances or positions,
michael@0 310 + depending which API we're using to actually draw. The types involved
michael@0 311 + have the same size, so this is safe. */
michael@0 312 CGSize *cg_advances = &cg_advances_static[0];
michael@0 313
michael@0 314 cairo_rectangle_int_t glyph_extents;
michael@0 315 cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
michael@0 316 cairo_int_status_t rv = CAIRO_STATUS_SUCCESS;
michael@0 317 cairo_quartz_drawing_state_t state;
michael@0 318 cairo_quartz_float_t xprev, yprev;
michael@0 319 int i;
michael@0 320 @@ -2796,41 +2814,62 @@ static cairo_int_status_t
michael@0 321 invTextTransform = CGAffineTransformMake (scaled_font->scale_inverse.xx,
michael@0 322 -scaled_font->scale_inverse.yx,
michael@0 323 scaled_font->scale_inverse.xy,
michael@0 324 -scaled_font->scale_inverse.yy,
michael@0 325 0.0, 0.0);
michael@0 326
michael@0 327 CGContextSetTextMatrix (state.context, CGAffineTransformIdentity);
michael@0 328
michael@0 329 - /* Convert our glyph positions to glyph advances. We need n-1 advances,
michael@0 330 - * since the advance at index 0 is applied after glyph 0. */
michael@0 331 - xprev = glyphs[0].x;
michael@0 332 - yprev = glyphs[0].y;
michael@0 333 -
michael@0 334 - cg_glyphs[0] = glyphs[0].index;
michael@0 335 -
michael@0 336 - for (i = 1; i < num_glyphs; i++) {
michael@0 337 - cairo_quartz_float_t xf = glyphs[i].x;
michael@0 338 - cairo_quartz_float_t yf = glyphs[i].y;
michael@0 339 - cg_glyphs[i] = glyphs[i].index;
michael@0 340 - cg_advances[i - 1] = CGSizeApplyAffineTransform(CGSizeMake (xf - xprev, yf - yprev), invTextTransform);
michael@0 341 - xprev = xf;
michael@0 342 - yprev = yf;
michael@0 343 - }
michael@0 344 -
michael@0 345 /* Translate to the first glyph's position before drawing */
michael@0 346 ctm = CGContextGetCTM (state.context);
michael@0 347 CGContextTranslateCTM (state.context, glyphs[0].x, glyphs[0].y);
michael@0 348 CGContextConcatCTM (state.context, textTransform);
michael@0 349
michael@0 350 - CGContextShowGlyphsWithAdvances (state.context,
michael@0 351 - cg_glyphs,
michael@0 352 - cg_advances,
michael@0 353 - num_glyphs);
michael@0 354 + if (CTFontDrawGlyphsPtr) {
michael@0 355 + /* If CTFontDrawGlyphs is available (i.e. OS X 10.7 or later), we want to use
michael@0 356 + * that in preference to CGContextShowGlyphsWithAdvances so that colored-bitmap
michael@0 357 + * fonts like Apple Color Emoji will render properly.
michael@0 358 + * For this, we need to convert our glyph positions to Core Graphics's CGPoint.
michael@0 359 + * We borrow the cg_advances array, as CGPoint and CGSize are the same size. */
michael@0 360 +
michael@0 361 + CGPoint *cg_positions = (CGPoint*) cg_advances;
michael@0 362 + cairo_quartz_float_t origin_x = glyphs[0].x;
michael@0 363 + cairo_quartz_float_t origin_y = glyphs[0].y;
michael@0 364 +
michael@0 365 + for (i = 0; i < num_glyphs; i++) {
michael@0 366 + CGPoint pt = CGPointMake (glyphs[i].x - origin_x, glyphs[i].y - origin_y);
michael@0 367 + cg_positions[i] = CGPointApplyAffineTransform (pt, invTextTransform);
michael@0 368 + cg_glyphs[i] = glyphs[i].index;
michael@0 369 + }
michael@0 370 +
michael@0 371 + CTFontDrawGlyphsPtr (_cairo_quartz_scaled_font_get_ct_font_ref (scaled_font),
michael@0 372 + cg_glyphs, cg_positions, num_glyphs, state.context);
michael@0 373 + } else {
michael@0 374 + /* Convert our glyph positions to glyph advances. We need n-1 advances,
michael@0 375 + * since the advance at index 0 is applied after glyph 0. */
michael@0 376 + xprev = glyphs[0].x;
michael@0 377 + yprev = glyphs[0].y;
michael@0 378 +
michael@0 379 + cg_glyphs[0] = glyphs[0].index;
michael@0 380 +
michael@0 381 + for (i = 1; i < num_glyphs; i++) {
michael@0 382 + cairo_quartz_float_t xf = glyphs[i].x;
michael@0 383 + cairo_quartz_float_t yf = glyphs[i].y;
michael@0 384 + cg_glyphs[i] = glyphs[i].index;
michael@0 385 + cg_advances[i - 1] = CGSizeApplyAffineTransform(CGSizeMake (xf - xprev, yf - yprev), invTextTransform);
michael@0 386 + xprev = xf;
michael@0 387 + yprev = yf;
michael@0 388 + }
michael@0 389 +
michael@0 390 + CGContextShowGlyphsWithAdvances (state.context,
michael@0 391 + cg_glyphs,
michael@0 392 + cg_advances,
michael@0 393 + num_glyphs);
michael@0 394 + }
michael@0 395
michael@0 396 CGContextSetCTM (state.context, ctm);
michael@0 397
michael@0 398 if (state.action == DO_IMAGE || state.action == DO_TILED_IMAGE ||
michael@0 399 state.action == DO_LAYER) {
michael@0 400 _cairo_quartz_draw_image (&state, op);
michael@0 401 } else if (state.action == DO_SHADING) {
michael@0 402 CGContextConcatCTM (state.context, state.transform);
michael@0 403 @@ -2847,20 +2886,27 @@ BAIL:
michael@0 404 cgfref &&
michael@0 405 !_cairo_operator_bounded_by_mask (op))
michael@0 406 {
michael@0 407 unbounded_op_data_t ub;
michael@0 408 ub.op = UNBOUNDED_SHOW_GLYPHS;
michael@0 409
michael@0 410 ub.u.show_glyphs.isClipping = isClipping;
michael@0 411 ub.u.show_glyphs.cg_glyphs = cg_glyphs;
michael@0 412 - ub.u.show_glyphs.cg_advances = cg_advances;
michael@0 413 + if (CTFontDrawGlyphsPtr) {
michael@0 414 + /* we're using Core Text API: the cg_advances array was
michael@0 415 + reused (above) for glyph positions */
michael@0 416 + CGPoint *cg_positions = (CGPoint*) cg_advances;
michael@0 417 + ub.u.show_glyphs.u.cg_positions = cg_positions;
michael@0 418 + } else {
michael@0 419 + ub.u.show_glyphs.u.cg_advances = cg_advances;
michael@0 420 + }
michael@0 421 ub.u.show_glyphs.nglyphs = num_glyphs;
michael@0 422 ub.u.show_glyphs.textTransform = textTransform;
michael@0 423 - ub.u.show_glyphs.font = cgfref;
michael@0 424 + ub.u.show_glyphs.scaled_font = scaled_font;
michael@0 425 ub.u.show_glyphs.origin = CGPointMake (glyphs[0].x, glyphs[0].y);
michael@0 426
michael@0 427 _cairo_quartz_fixup_unbounded_operation (surface, &ub, scaled_font->options.antialias);
michael@0 428 }
michael@0 429
michael@0 430
michael@0 431 if (cg_advances != &cg_advances_static[0]) {
michael@0 432 free (cg_advances);

mercurial