aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-22 19:49:08 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-03-22 19:49:08 +0000
commit6fa451862097987e8c608659fbb5fdf9dee24d96 (patch)
tree79497ea01fe1c89ba75b277d44574f1b93e05106 /src/ports
parenta03ec86e997ce08fad354a4102080b3163244b6a (diff)
inline knowledge that our pointsize is always 1 when we measure/draw
#ifdef protect 10.6 or later APIs (not available on 10.5) git-svn-id: http://skia.googlecode.com/svn/trunk@982 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontHost_mac_coretext.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp
index c38d2fddc6..6ffe17b403 100644
--- a/src/ports/SkFontHost_mac_coretext.cpp
+++ b/src/ports/SkFontHost_mac_coretext.cpp
@@ -30,9 +30,6 @@ static const SkFontID kSkInvalidFontID = 0;
static const size_t FONT_CACHE_MEMORY_BUDGET = 1024 * 1024;
static const char FONT_DEFAULT_NAME[] = "Lucida Sans";
-static const float FONT_CANONICAL_POINTSIZE = 1.0f;
-
-
typedef struct {
SkString name;
SkTypeface::Style style;
@@ -257,9 +254,6 @@ CTFontRef SkNativeFontCache::CreateNativeFont(const char familyName[],
// Create the font
- //
- // Fonts are scaled using the Sk matrix, so we always request a font
- // at a canonical size FONT_CANONICAL_POINTSIZE
if (cfFontName != NULL && cfFontTraits != NULL && cfAttributes != NULL && cfTraits != NULL) {
CFDictionaryAddValue(cfTraits, kCTFontSymbolicTrait, cfFontTraits);
@@ -268,7 +262,7 @@ CTFontRef SkNativeFontCache::CreateNativeFont(const char familyName[],
ctFontDesc = CTFontDescriptorCreateWithAttributes(cfAttributes);
if (ctFontDesc != NULL) {
- ctFont = CTFontCreateWithFontDescriptor(ctFontDesc, FONT_CANONICAL_POINTSIZE, NULL);
+ ctFont = CTFontCreateWithFontDescriptor(ctFontDesc, 0, NULL);
}
}
@@ -358,15 +352,15 @@ SkScalerContext_Mac::SkScalerContext_Mac(const SkDescriptor* desc)
mColorSpaceRGB = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGBLinear);
mColorSpaceGray = CGColorSpaceCreateDeviceGray();
- const float inv = 1.0f / FONT_CANONICAL_POINTSIZE;
- mTransform = CGAffineTransformMake(SkScalarToFloat(skMatrix[SkMatrix::kMScaleX]) * inv,
- -SkScalarToFloat(skMatrix[SkMatrix::kMSkewY]) * inv,
- -SkScalarToFloat(skMatrix[SkMatrix::kMSkewX]) * inv,
- SkScalarToFloat(skMatrix[SkMatrix::kMScaleY]) * inv,
- SkScalarToFloat(skMatrix[SkMatrix::kMTransX]) * inv,
- SkScalarToFloat(skMatrix[SkMatrix::kMTransY]) * inv);
+ mTransform = CGAffineTransformMake(SkScalarToFloat(skMatrix[SkMatrix::kMScaleX]),
+ -SkScalarToFloat(skMatrix[SkMatrix::kMSkewY]),
+ -SkScalarToFloat(skMatrix[SkMatrix::kMSkewX]),
+ SkScalarToFloat(skMatrix[SkMatrix::kMScaleY]),
+ SkScalarToFloat(skMatrix[SkMatrix::kMTransX]),
+ SkScalarToFloat(skMatrix[SkMatrix::kMTransY]));
- mFont = CTFontCreateCopyWithAttributes(ctFont, 0.0, &mTransform, NULL);
+ // since our matrix includes everything, we pass 1 for pointSize
+ mFont = CTFontCreateCopyWithAttributes(ctFont, 1, &mTransform, NULL);
mGlyphCount = (uint16_t) numGlyphs;
}
@@ -503,13 +497,14 @@ void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) {
// Draw the glyph
if (cgFont != NULL && cgContext != NULL) {
+#ifdef WE_ARE_RUNNING_ON_10_6_OR_LATER
CGContextSetAllowsFontSubpixelQuantization(cgContext, true);
CGContextSetShouldSubpixelQuantizeFonts(cgContext, true);
-
+#endif
CGContextSetGrayFillColor( cgContext, grayColor, 1.0);
CGContextSetTextDrawingMode(cgContext, kCGTextFill);
CGContextSetFont( cgContext, cgFont);
- CGContextSetFontSize( cgContext, FONT_CANONICAL_POINTSIZE);
+ CGContextSetFontSize( cgContext, 1); // cgFont know's its size
CGContextSetTextMatrix( cgContext, mTransform);
CGContextShowGlyphsAtPoint( cgContext, -glyph.fLeft, glyph.fTop + glyph.fHeight, &cgGlyph, 1);