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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 CTFontRef originalCTFont = fFontRef.get(); | 1532 CTFontRef originalCTFont = fFontRef.get(); |
1533 AutoCFRelease<CTFontRef> ctFont(CTFontCreateCopyWithAttributes( | 1533 AutoCFRelease<CTFontRef> ctFont(CTFontCreateCopyWithAttributes( |
1534 originalCTFont, CTFontGetUnitsPerEm(originalCTFont), NULL, NULL)); | 1534 originalCTFont, CTFontGetUnitsPerEm(originalCTFont), NULL, NULL)); |
1535 SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; | 1535 SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; |
1536 | 1536 |
1537 { | 1537 { |
1538 AutoCFRelease<CFStringRef> fontName(CTFontCopyPostScriptName(ctFont)); | 1538 AutoCFRelease<CFStringRef> fontName(CTFontCopyPostScriptName(ctFont)); |
1539 CFStringToSkString(fontName, &info->fFontName); | 1539 CFStringToSkString(fontName, &info->fFontName); |
1540 } | 1540 } |
1541 | 1541 |
1542 info->fMultiMaster = false; | |
1543 CFIndex glyphCount = CTFontGetGlyphCount(ctFont); | 1542 CFIndex glyphCount = CTFontGetGlyphCount(ctFont); |
1544 info->fLastGlyphID = SkToU16(glyphCount - 1); | 1543 info->fLastGlyphID = SkToU16(glyphCount - 1); |
1545 info->fEmSize = CTFontGetUnitsPerEm(ctFont); | 1544 info->fEmSize = CTFontGetUnitsPerEm(ctFont); |
1546 | 1545 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag; |
1547 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) { | |
1548 populate_glyph_to_unicode(ctFont, glyphCount, &info->fGlyphToUnicode); | |
1549 } | |
1550 | |
1551 info->fStyle = 0; | 1546 info->fStyle = 0; |
1552 | 1547 |
1553 // If it's not a truetype font, mark it as 'other'. Assume that TrueType | 1548 // If it's not a truetype font, mark it as 'other'. Assume that TrueType |
1554 // fonts always have both glyf and loca tables. At the least, this is what | 1549 // fonts always have both glyf and loca tables. At the least, this is what |
1555 // sfntly needs to subset the font. CTFontCopyAttribute() does not always | 1550 // sfntly needs to subset the font. CTFontCopyAttribute() does not always |
1556 // succeed in determining this directly. | 1551 // succeed in determining this directly. |
1557 if (!this->getTableSize('glyf') || !this->getTableSize('loca')) { | 1552 if (!this->getTableSize('glyf') || !this->getTableSize('loca')) { |
1558 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; | 1553 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; |
1559 info->fItalicAngle = 0; | 1554 info->fItalicAngle = 0; |
1560 info->fAscent = 0; | 1555 info->fAscent = 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 glyphs, boundingRects, count); | 1601 glyphs, boundingRects, count); |
1607 for (size_t i = 0; i < count; i++) { | 1602 for (size_t i = 0; i < count; i++) { |
1608 int16_t width = (int16_t) boundingRects[i].size.width; | 1603 int16_t width = (int16_t) boundingRects[i].size.width; |
1609 if (width > 0 && width < min_width) { | 1604 if (width > 0 && width < min_width) { |
1610 min_width = width; | 1605 min_width = width; |
1611 info->fStemV = min_width; | 1606 info->fStemV = min_width; |
1612 } | 1607 } |
1613 } | 1608 } |
1614 } | 1609 } |
1615 | 1610 |
1616 if (false) { // TODO: haven't figured out how to know if font is embeddable | 1611 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) { |
1617 // (information is in the OS/2 table) | |
1618 info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font; | |
1619 } else if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo)
{ | |
1620 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { | 1612 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { |
1621 skia_advanced_typeface_metrics_utils::appendRange(&info->fGlyphWidth
s, 0); | 1613 skia_advanced_typeface_metrics_utils::appendRange(&info->fGlyphWidth
s, 0); |
1622 info->fGlyphWidths->fAdvance.append(1, &min_width); | 1614 info->fGlyphWidths->fAdvance.append(1, &min_width); |
1623 skia_advanced_typeface_metrics_utils::finishRange(info->fGlyphWidths
.get(), 0, | 1615 skia_advanced_typeface_metrics_utils::finishRange(info->fGlyphWidths
.get(), 0, |
1624 SkAdvancedTypefaceMetrics::WidthRange::kDefault); | 1616 SkAdvancedTypefaceMetrics::WidthRange::kDefault); |
1625 } else { | 1617 } else { |
1626 info->fGlyphWidths.reset( | 1618 info->fGlyphWidths.reset( |
1627 skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get(
), | 1619 skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get(
), |
1628 glyphCount, | 1620 glyphCount, |
1629 glyphIDs, | 1621 glyphIDs, |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); | 2299 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); |
2308 } | 2300 } |
2309 }; | 2301 }; |
2310 | 2302 |
2311 /////////////////////////////////////////////////////////////////////////////// | 2303 /////////////////////////////////////////////////////////////////////////////// |
2312 | 2304 |
2313 SkFontMgr* SkFontMgr::Factory() { | 2305 SkFontMgr* SkFontMgr::Factory() { |
2314 return SkNEW(SkFontMgr_Mac); | 2306 return SkNEW(SkFontMgr_Mac); |
2315 } | 2307 } |
2316 #endif | 2308 #endif |
OLD | NEW |