aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_mac_coretext.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-19 16:09:26 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-12-19 16:09:26 +0000
commit8f3c44aeeb28c1f78d160bd15818a5fd3ecdcd4a (patch)
tree612aa54c0dba3302b3db37fcf57edc88253a9e89 /src/ports/SkFontHost_mac_coretext.cpp
parent24569b5bad4156a1eb95da92c96fc96b41e11622 (diff)
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
Diffstat (limited to 'src/ports/SkFontHost_mac_coretext.cpp')
-rw-r--r--src/ports/SkFontHost_mac_coretext.cpp25
1 files changed, 21 insertions, 4 deletions
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;