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