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 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 public: | 649 public: |
650 SkScalerContext_Mac(SkTypeface_Mac*, const SkDescriptor*); | 650 SkScalerContext_Mac(SkTypeface_Mac*, const SkDescriptor*); |
651 | 651 |
652 protected: | 652 protected: |
653 unsigned generateGlyphCount(void) SK_OVERRIDE; | 653 unsigned generateGlyphCount(void) SK_OVERRIDE; |
654 uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; | 654 uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; |
655 void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; | 655 void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; |
656 void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; | 656 void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; |
657 void generateImage(const SkGlyph& glyph) SK_OVERRIDE; | 657 void generateImage(const SkGlyph& glyph) SK_OVERRIDE; |
658 void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; | 658 void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; |
659 void generateFontMetrics(SkPaint::FontMetrics* mX, SkPaint::FontMetrics* mY)
SK_OVERRIDE; | 659 void generateFontMetrics(SkPaint::FontMetrics*) SK_OVERRIDE; |
660 | 660 |
661 private: | 661 private: |
662 static void CTPathElement(void *info, const CGPathElement *element); | 662 static void CTPathElement(void *info, const CGPathElement *element); |
663 | 663 |
664 /** Returns the offset from the horizontal origin to the vertical origin in
SkGlyph units. */ | 664 /** Returns the offset from the horizontal origin to the vertical origin in
SkGlyph units. */ |
665 void getVerticalOffset(CGGlyph glyphID, SkPoint* offset) const; | 665 void getVerticalOffset(CGGlyph glyphID, SkPoint* offset) const; |
666 | 666 |
667 /** Initializes and returns the value of fFBoundingBoxesGlyphOffset. | 667 /** Initializes and returns the value of fFBoundingBoxesGlyphOffset. |
668 * | 668 * |
669 * For use with (and must be called before) generateBBoxes. | 669 * For use with (and must be called before) generateBBoxes. |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 // balance the call to CTFontCreateCopyWithAttributes | 1361 // balance the call to CTFontCreateCopyWithAttributes |
1362 CFSafeRelease(font); | 1362 CFSafeRelease(font); |
1363 } | 1363 } |
1364 if (fVertical) { | 1364 if (fVertical) { |
1365 SkPoint offset; | 1365 SkPoint offset; |
1366 getVerticalOffset(cgGlyph, &offset); | 1366 getVerticalOffset(cgGlyph, &offset); |
1367 path->offset(offset.fX, offset.fY); | 1367 path->offset(offset.fX, offset.fY); |
1368 } | 1368 } |
1369 } | 1369 } |
1370 | 1370 |
1371 void SkScalerContext_Mac::generateFontMetrics(SkPaint::FontMetrics* mx, | 1371 void SkScalerContext_Mac::generateFontMetrics(SkPaint::FontMetrics* metrics) { |
1372 SkPaint::FontMetrics* my) { | 1372 if (NULL == metrics) { |
| 1373 return; |
| 1374 } |
| 1375 |
1373 CGRect theBounds = CTFontGetBoundingBox(fCTFont); | 1376 CGRect theBounds = CTFontGetBoundingBox(fCTFont); |
1374 | 1377 |
1375 SkPaint::FontMetrics theMetrics; | 1378 metrics->fTop = CGToScalar(-CGRectGetMaxY_inline(theBounds)); |
1376 theMetrics.fTop = CGToScalar(-CGRectGetMaxY_inline(theBounds)); | 1379 metrics->fAscent = CGToScalar(-CTFontGetAscent(fCTFont)); |
1377 theMetrics.fAscent = CGToScalar(-CTFontGetAscent(fCTFont)); | 1380 metrics->fDescent = CGToScalar( CTFontGetDescent(fCTFont)); |
1378 theMetrics.fDescent = CGToScalar( CTFontGetDescent(fCTFont)); | 1381 metrics->fBottom = CGToScalar(-CGRectGetMinY_inline(theBounds)); |
1379 theMetrics.fBottom = CGToScalar(-CGRectGetMinY_inline(theBounds)); | 1382 metrics->fLeading = CGToScalar( CTFontGetLeading(fCTFont)); |
1380 theMetrics.fLeading = CGToScalar( CTFontGetLeading(fCTFont)); | 1383 metrics->fAvgCharWidth = CGToScalar( CGRectGetWidth_inline(theBounds)); |
1381 theMetrics.fAvgCharWidth = CGToScalar( CGRectGetWidth_inline(theBounds)); | 1384 metrics->fXMin = CGToScalar( CGRectGetMinX_inline(theBounds)); |
1382 theMetrics.fXMin = CGToScalar( CGRectGetMinX_inline(theBounds)); | 1385 metrics->fXMax = CGToScalar( CGRectGetMaxX_inline(theBounds)); |
1383 theMetrics.fXMax = CGToScalar( CGRectGetMaxX_inline(theBounds)); | 1386 metrics->fXHeight = CGToScalar( CTFontGetXHeight(fCTFont)); |
1384 theMetrics.fXHeight = CGToScalar( CTFontGetXHeight(fCTFont)); | 1387 metrics->fUnderlineThickness = CGToScalar( CTFontGetUnderlineThickness(fCTFo
nt)); |
1385 theMetrics.fUnderlineThickness = CGToScalar( CTFontGetUnderlineThickness(fCT
Font)); | 1388 metrics->fUnderlinePosition = -CGToScalar( CTFontGetUnderlinePosition(fCTFon
t)); |
1386 theMetrics.fUnderlinePosition = -CGToScalar( CTFontGetUnderlinePosition(fCTF
ont)); | |
1387 | 1389 |
1388 theMetrics.fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; | 1390 metrics->fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag; |
1389 theMetrics.fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; | 1391 metrics->fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag; |
1390 | |
1391 if (mx != NULL) { | |
1392 *mx = theMetrics; | |
1393 } | |
1394 if (my != NULL) { | |
1395 *my = theMetrics; | |
1396 } | |
1397 } | 1392 } |
1398 | 1393 |
1399 void SkScalerContext_Mac::CTPathElement(void *info, const CGPathElement *element
) { | 1394 void SkScalerContext_Mac::CTPathElement(void *info, const CGPathElement *element
) { |
1400 SkPath* skPath = (SkPath*)info; | 1395 SkPath* skPath = (SkPath*)info; |
1401 | 1396 |
1402 // Process the path element | 1397 // Process the path element |
1403 switch (element->type) { | 1398 switch (element->type) { |
1404 case kCGPathElementMoveToPoint: | 1399 case kCGPathElementMoveToPoint: |
1405 skPath->moveTo(element->points[0].x, -element->points[0].y); | 1400 skPath->moveTo(element->points[0].x, -element->points[0].y); |
1406 break; | 1401 break; |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); | 2308 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); |
2314 } | 2309 } |
2315 }; | 2310 }; |
2316 | 2311 |
2317 /////////////////////////////////////////////////////////////////////////////// | 2312 /////////////////////////////////////////////////////////////////////////////// |
2318 | 2313 |
2319 SkFontMgr* SkFontMgr::Factory() { | 2314 SkFontMgr* SkFontMgr::Factory() { |
2320 return SkNEW(SkFontMgr_Mac); | 2315 return SkNEW(SkFontMgr_Mac); |
2321 } | 2316 } |
2322 #endif | 2317 #endif |
OLD | NEW |