From 8f3c44aeeb28c1f78d160bd15818a5fd3ecdcd4a Mon Sep 17 00:00:00 2001 From: "caryclark@google.com" Date: Mon, 19 Dec 2011 16:09:26 +0000 Subject: partial fix for vertical text on Lion M src/ports/SkFontHost_mac_coretext.cpp git-svn-id: http://skia.googlecode.com/svn/trunk@2896 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/ports/SkFontHost_mac_coretext.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/ports/SkFontHost_mac_coretext.cpp') diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp index b125265f40..423f0af98c 100644 --- a/src/ports/SkFontHost_mac_coretext.cpp +++ b/src/ports/SkFontHost_mac_coretext.cpp @@ -931,11 +931,26 @@ void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) { // Get the state we need cgGlyph = (CGGlyph) glyph->getGlyphID(fBaseGlyphCount); - CTFontGetBoundingRectsForGlyphs(fCTFont, kCTFontDefaultOrientation, &cgGlyph, &theBounds, 1); if (fVertical) { - CTFontGetAdvancesForGlyphs(fCTVerticalFont, kCTFontVerticalOrientation, &cgGlyph, &theAdvance, 1); + if (isLion()) { + // Lion correctly supports returning the bounding box for vertical text. + CTFontGetBoundingRectsForGlyphs(fCTVerticalFont, + kCTFontVerticalOrientation, + &cgGlyph, &theBounds, 1); + } else { + /* Snow Leopard and earlier respect the vertical font metrics for + advances, but not bounds, so use the default box and adjust it below. + */ + CTFontGetBoundingRectsForGlyphs(fCTFont, kCTFontDefaultOrientation, + &cgGlyph, &theBounds, 1); + } + CTFontGetAdvancesForGlyphs(fCTVerticalFont, kCTFontVerticalOrientation, + &cgGlyph, &theAdvance, 1); } else { - CTFontGetAdvancesForGlyphs(fCTFont, kCTFontDefaultOrientation, &cgGlyph, &theAdvance, 1); + CTFontGetBoundingRectsForGlyphs(fCTFont, kCTFontDefaultOrientation, + &cgGlyph, &theBounds, 1); + CTFontGetAdvancesForGlyphs(fCTFont, kCTFontDefaultOrientation, + &cgGlyph, &theAdvance, 1); } // BUG? @@ -983,9 +998,11 @@ void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) { CGRectInset_inline(&theBounds, -1, -1); // Get the metrics + bool lionAdjustedMetrics = false; if (isLion()) { if (cgGlyph < fGlyphCount && cgGlyph >= getAdjustStart() && generateBBoxes()) { + lionAdjustedMetrics = true; SkRect adjust; const GlyphRect& gRect = fAdjustBad[cgGlyph - fAdjustStart]; adjust.set(gRect.fMinX, gRect.fMinY, gRect.fMaxX, gRect.fMaxY); @@ -1003,7 +1020,7 @@ void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) { glyph->fTop = -sk_float_round2int(CGRectGetMaxY_inline(theBounds)); glyph->fLeft = sk_float_round2int(CGRectGetMinX_inline(theBounds)); SkIPoint offset; - if (fVertical) { + if (fVertical && (!isLion() || lionAdjustedMetrics)) { getVerticalOffset(cgGlyph, &offset); glyph->fLeft += offset.fX; glyph->fTop += offset.fY; -- cgit v1.2.3