OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 #ifdef SK_BUILD_FOR_MAC | 10 #ifdef SK_BUILD_FOR_MAC |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 // It is documented that if a mapping is unavailable, the glyph will be set
to 0. | 951 // It is documented that if a mapping is unavailable, the glyph will be set
to 0. |
952 CTFontGetGlyphsForCharacters(fCTFont, theChar, cgGlyph, numUniChar); | 952 CTFontGetGlyphsForCharacters(fCTFont, theChar, cgGlyph, numUniChar); |
953 return cgGlyph[0]; | 953 return cgGlyph[0]; |
954 } | 954 } |
955 | 955 |
956 void SkScalerContext_Mac::generateAdvance(SkGlyph* glyph) { | 956 void SkScalerContext_Mac::generateAdvance(SkGlyph* glyph) { |
957 this->generateMetrics(glyph); | 957 this->generateMetrics(glyph); |
958 } | 958 } |
959 | 959 |
960 void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) { | 960 void SkScalerContext_Mac::generateMetrics(SkGlyph* glyph) { |
961 const CGGlyph cgGlyph = (CGGlyph) glyph->getGlyphID(fBaseGlyphCount); | 961 const CGGlyph cgGlyph = (CGGlyph) glyph->getGlyphID(); |
962 glyph->zeroMetrics(); | 962 glyph->zeroMetrics(); |
963 | 963 |
964 // The following block produces cgAdvance in CG units (pixels, y up). | 964 // The following block produces cgAdvance in CG units (pixels, y up). |
965 CGSize cgAdvance; | 965 CGSize cgAdvance; |
966 if (fVertical) { | 966 if (fVertical) { |
967 CTFontGetAdvancesForGlyphs(fCTVerticalFont, kCTFontVerticalOrientation, | 967 CTFontGetAdvancesForGlyphs(fCTVerticalFont, kCTFontVerticalOrientation, |
968 &cgGlyph, &cgAdvance, 1); | 968 &cgGlyph, &cgAdvance, 1); |
969 } else { | 969 } else { |
970 CTFontGetAdvancesForGlyphs(fCTFont, kCTFontHorizontalOrientation, | 970 CTFontGetAdvancesForGlyphs(fCTFont, kCTFontHorizontalOrientation, |
971 &cgGlyph, &cgAdvance, 1); | 971 &cgGlyph, &cgAdvance, 1); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 b = (glyph.fHeight - y) * 255 / glyph.fHeight; | 1196 b = (glyph.fHeight - y) * 255 / glyph.fHeight; |
1197 return SkPreMultiplyARGB(a, r, g, b); // red | 1197 return SkPreMultiplyARGB(a, r, g, b); // red |
1198 } | 1198 } |
1199 #endif | 1199 #endif |
1200 | 1200 |
1201 template <typename T> T* SkTAddByteOffset(T* ptr, size_t byteOffset) { | 1201 template <typename T> T* SkTAddByteOffset(T* ptr, size_t byteOffset) { |
1202 return (T*)((char*)ptr + byteOffset); | 1202 return (T*)((char*)ptr + byteOffset); |
1203 } | 1203 } |
1204 | 1204 |
1205 void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) { | 1205 void SkScalerContext_Mac::generateImage(const SkGlyph& glyph) { |
1206 CGGlyph cgGlyph = (CGGlyph) glyph.getGlyphID(fBaseGlyphCount); | 1206 CGGlyph cgGlyph = (CGGlyph) glyph.getGlyphID(); |
1207 | 1207 |
1208 // FIXME: lcd smoothed un-hinted rasterization unsupported. | 1208 // FIXME: lcd smoothed un-hinted rasterization unsupported. |
1209 bool generateA8FromLCD = fRec.getHinting() != SkPaint::kNo_Hinting; | 1209 bool generateA8FromLCD = fRec.getHinting() != SkPaint::kNo_Hinting; |
1210 | 1210 |
1211 // Draw the glyph | 1211 // Draw the glyph |
1212 size_t cgRowBytes; | 1212 size_t cgRowBytes; |
1213 CGRGBPixel* cgPixels = fOffscreen.getCG(*this, glyph, cgGlyph, &cgRowBytes,
generateA8FromLCD); | 1213 CGRGBPixel* cgPixels = fOffscreen.getCG(*this, glyph, cgGlyph, &cgRowBytes,
generateA8FromLCD); |
1214 if (cgPixels == NULL) { | 1214 if (cgPixels == NULL) { |
1215 return; | 1215 return; |
1216 } | 1216 } |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 break; | 1335 break; |
1336 default: | 1336 default: |
1337 break; | 1337 break; |
1338 } | 1338 } |
1339 | 1339 |
1340 CGAffineTransform xform = MatrixToCGAffineTransform(m, scaleX, scaleY); | 1340 CGAffineTransform xform = MatrixToCGAffineTransform(m, scaleX, scaleY); |
1341 // need to release font when we're done | 1341 // need to release font when we're done |
1342 font = CTFontCreateCopyWithAttributes(fCTFont, 1, &xform, NULL); | 1342 font = CTFontCreateCopyWithAttributes(fCTFont, 1, &xform, NULL); |
1343 } | 1343 } |
1344 | 1344 |
1345 CGGlyph cgGlyph = (CGGlyph)glyph.getGlyphID(fBaseGlyphCount); | 1345 CGGlyph cgGlyph = (CGGlyph)glyph.getGlyphID(); |
1346 AutoCFRelease<CGPathRef> cgPath(CTFontCreatePathForGlyph(font, cgGlyph, NULL
)); | 1346 AutoCFRelease<CGPathRef> cgPath(CTFontCreatePathForGlyph(font, cgGlyph, NULL
)); |
1347 | 1347 |
1348 path->reset(); | 1348 path->reset(); |
1349 if (cgPath != NULL) { | 1349 if (cgPath != NULL) { |
1350 CGPathApply(cgPath, path, SkScalerContext_Mac::CTPathElement); | 1350 CGPathApply(cgPath, path, SkScalerContext_Mac::CTPathElement); |
1351 } | 1351 } |
1352 | 1352 |
1353 if (fDoSubPosition) { | 1353 if (fDoSubPosition) { |
1354 SkMatrix m; | 1354 SkMatrix m; |
1355 m.setScale(SkScalarInvert(scaleX), SkScalarInvert(scaleY)); | 1355 m.setScale(SkScalarInvert(scaleX), SkScalarInvert(scaleY)); |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); | 2304 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); |
2305 } | 2305 } |
2306 }; | 2306 }; |
2307 | 2307 |
2308 /////////////////////////////////////////////////////////////////////////////// | 2308 /////////////////////////////////////////////////////////////////////////////// |
2309 | 2309 |
2310 SkFontMgr* SkFontMgr::Factory() { | 2310 SkFontMgr* SkFontMgr::Factory() { |
2311 return SkNEW(SkFontMgr_Mac); | 2311 return SkNEW(SkFontMgr_Mac); |
2312 } | 2312 } |
2313 #endif | 2313 #endif |
OLD | NEW |