| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkTypes.h" // Keep this before any #ifdef ... | 8 #include "SkTypes.h" // Keep this before any #ifdef ... |
| 9 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 9 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
| 10 | 10 |
| (...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 for (size_t i = 0; i < count; i++) { | 1603 for (size_t i = 0; i < count; i++) { |
| 1604 int16_t width = (int16_t) boundingRects[i].size.width; | 1604 int16_t width = (int16_t) boundingRects[i].size.width; |
| 1605 if (width > 0 && width < min_width) { | 1605 if (width > 0 && width < min_width) { |
| 1606 min_width = width; | 1606 min_width = width; |
| 1607 info->fStemV = min_width; | 1607 info->fStemV = min_width; |
| 1608 } | 1608 } |
| 1609 } | 1609 } |
| 1610 } | 1610 } |
| 1611 | 1611 |
| 1612 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { | 1612 if (perGlyphInfo & kHAdvance_PerGlyphInfo) { |
| 1613 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { | 1613 CTFontRef borrowedCTFont = ctFont.get(); |
| 1614 SkAdvancedTypefaceMetrics::WidthRange range(0); | 1614 info->setGlyphWidths( |
| 1615 range.fAdvance.append(1, &min_width); | 1615 SkToInt(glyphCount), |
| 1616 SkAdvancedTypefaceMetrics::FinishRange( | 1616 glyphIDs, |
| 1617 &range, 0, SkAdvancedTypefaceMetrics::WidthRange::kDefault); | 1617 glyphIDsCount, |
| 1618 info->fGlyphWidths.emplace_back(std::move(range)); | 1618 SkAdvancedTypefaceMetrics::GetAdvance([borrowedCTFont](int gId, int1
6_t* data) { |
| 1619 } else { | 1619 CGSize advance; |
| 1620 CTFontRef borrowedCTFont = ctFont.get(); | 1620 advance.width = 0; |
| 1621 info->setGlyphWidths( | 1621 CGGlyph glyph = gId; |
| 1622 SkToInt(glyphCount), | 1622 CTFontGetAdvancesForGlyphs(borrowedCTFont, kCTFontHorizontalOrie
ntation, |
| 1623 glyphIDs, | 1623 &glyph, &advance, 1); |
| 1624 glyphIDsCount, | 1624 *data = sk_float_round2int(advance.width); |
| 1625 SkAdvancedTypefaceMetrics::GetAdvance([borrowedCTFont](int gId,
int16_t* data) { | 1625 return true; |
| 1626 CGSize advance; | 1626 }) |
| 1627 advance.width = 0; | 1627 ); |
| 1628 CGGlyph glyph = gId; | |
| 1629 CTFontGetAdvancesForGlyphs(borrowedCTFont, kCTFontHorizontal
Orientation, | |
| 1630 &glyph, &advance, 1); | |
| 1631 *data = sk_float_round2int(advance.width); | |
| 1632 return true; | |
| 1633 }) | |
| 1634 ); | |
| 1635 } | |
| 1636 } | 1628 } |
| 1637 return info; | 1629 return info; |
| 1638 } | 1630 } |
| 1639 | 1631 |
| 1640 /////////////////////////////////////////////////////////////////////////////// | 1632 /////////////////////////////////////////////////////////////////////////////// |
| 1641 | 1633 |
| 1642 static SK_SFNT_ULONG get_font_type_tag(const SkTypeface_Mac* typeface) { | 1634 static SK_SFNT_ULONG get_font_type_tag(const SkTypeface_Mac* typeface) { |
| 1643 CTFontRef ctFont = typeface->fFontRef.get(); | 1635 CTFontRef ctFont = typeface->fFontRef.get(); |
| 1644 AutoCFRelease<CFNumberRef> fontFormatRef( | 1636 AutoCFRelease<CFNumberRef> fontFormatRef( |
| 1645 static_cast<CFNumberRef>(CTFontCopyAttribute(ctFont, kCTFontFormatAt
tribute))); | 1637 static_cast<CFNumberRef>(CTFontCopyAttribute(ctFont, kCTFontFormatAt
tribute))); |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2577 | 2569 |
| 2578 return SkSafeRef(GetDefaultFace()); | 2570 return SkSafeRef(GetDefaultFace()); |
| 2579 } | 2571 } |
| 2580 }; | 2572 }; |
| 2581 | 2573 |
| 2582 /////////////////////////////////////////////////////////////////////////////// | 2574 /////////////////////////////////////////////////////////////////////////////// |
| 2583 | 2575 |
| 2584 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } | 2576 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } |
| 2585 | 2577 |
| 2586 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) | 2578 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) |
| OLD | NEW |