Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Side by Side Diff: src/ports/SkFontHost_mac.cpp

Issue 334443002: [PDF] Fix font embedding restrictions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkFontHost_FreeType.cpp ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 CTFontRef originalCTFont = fFontRef.get(); 1537 CTFontRef originalCTFont = fFontRef.get();
1538 AutoCFRelease<CTFontRef> ctFont(CTFontCreateCopyWithAttributes( 1538 AutoCFRelease<CTFontRef> ctFont(CTFontCreateCopyWithAttributes(
1539 originalCTFont, CTFontGetUnitsPerEm(originalCTFont), NULL, NULL)); 1539 originalCTFont, CTFontGetUnitsPerEm(originalCTFont), NULL, NULL));
1540 SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics; 1540 SkAdvancedTypefaceMetrics* info = new SkAdvancedTypefaceMetrics;
1541 1541
1542 { 1542 {
1543 AutoCFRelease<CFStringRef> fontName(CTFontCopyPostScriptName(ctFont)); 1543 AutoCFRelease<CFStringRef> fontName(CTFontCopyPostScriptName(ctFont));
1544 CFStringToSkString(fontName, &info->fFontName); 1544 CFStringToSkString(fontName, &info->fFontName);
1545 } 1545 }
1546 1546
1547 info->fMultiMaster = false;
1548 CFIndex glyphCount = CTFontGetGlyphCount(ctFont); 1547 CFIndex glyphCount = CTFontGetGlyphCount(ctFont);
1549 info->fLastGlyphID = SkToU16(glyphCount - 1); 1548 info->fLastGlyphID = SkToU16(glyphCount - 1);
1550 info->fEmSize = CTFontGetUnitsPerEm(ctFont); 1549 info->fEmSize = CTFontGetUnitsPerEm(ctFont);
1550 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag;
1551 info->fStyle = 0;
1551 1552
1552 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) { 1553 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) {
1553 populate_glyph_to_unicode(ctFont, glyphCount, &info->fGlyphToUnicode); 1554 populate_glyph_to_unicode(ctFont, glyphCount, &info->fGlyphToUnicode);
1554 } 1555 }
1555 1556
1556 info->fStyle = 0;
1557
1558 // If it's not a truetype font, mark it as 'other'. Assume that TrueType 1557 // If it's not a truetype font, mark it as 'other'. Assume that TrueType
1559 // fonts always have both glyf and loca tables. At the least, this is what 1558 // fonts always have both glyf and loca tables. At the least, this is what
1560 // sfntly needs to subset the font. CTFontCopyAttribute() does not always 1559 // sfntly needs to subset the font. CTFontCopyAttribute() does not always
1561 // succeed in determining this directly. 1560 // succeed in determining this directly.
1562 if (!this->getTableSize('glyf') || !this->getTableSize('loca')) { 1561 if (!this->getTableSize('glyf') || !this->getTableSize('loca')) {
1563 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; 1562 info->fType = SkAdvancedTypefaceMetrics::kOther_Font;
1564 info->fItalicAngle = 0; 1563 info->fItalicAngle = 0;
1565 info->fAscent = 0; 1564 info->fAscent = 0;
1566 info->fDescent = 0; 1565 info->fDescent = 0;
1567 info->fStemV = 0; 1566 info->fStemV = 0;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 glyphs, boundingRects, count); 1610 glyphs, boundingRects, count);
1612 for (size_t i = 0; i < count; i++) { 1611 for (size_t i = 0; i < count; i++) {
1613 int16_t width = (int16_t) boundingRects[i].size.width; 1612 int16_t width = (int16_t) boundingRects[i].size.width;
1614 if (width > 0 && width < min_width) { 1613 if (width > 0 && width < min_width) {
1615 min_width = width; 1614 min_width = width;
1616 info->fStemV = min_width; 1615 info->fStemV = min_width;
1617 } 1616 }
1618 } 1617 }
1619 } 1618 }
1620 1619
1621 if (false) { // TODO: haven't figured out how to know if font is embeddable 1620 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
1622 // (information is in the OS/2 table)
1623 info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
1624 } else if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
1625 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) { 1621 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) {
1626 skia_advanced_typeface_metrics_utils::appendRange(&info->fGlyphWidth s, 0); 1622 skia_advanced_typeface_metrics_utils::appendRange(&info->fGlyphWidth s, 0);
1627 info->fGlyphWidths->fAdvance.append(1, &min_width); 1623 info->fGlyphWidths->fAdvance.append(1, &min_width);
1628 skia_advanced_typeface_metrics_utils::finishRange(info->fGlyphWidths .get(), 0, 1624 skia_advanced_typeface_metrics_utils::finishRange(info->fGlyphWidths .get(), 0,
1629 SkAdvancedTypefaceMetrics::WidthRange::kDefault); 1625 SkAdvancedTypefaceMetrics::WidthRange::kDefault);
1630 } else { 1626 } else {
1631 info->fGlyphWidths.reset( 1627 info->fGlyphWidths.reset(
1632 skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get( ), 1628 skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get( ),
1633 SkToInt(glyphCount), 1629 SkToInt(glyphCount),
1634 glyphIDs, 1630 glyphIDs,
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); 2306 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits);
2311 } 2307 }
2312 }; 2308 };
2313 2309
2314 /////////////////////////////////////////////////////////////////////////////// 2310 ///////////////////////////////////////////////////////////////////////////////
2315 2311
2316 SkFontMgr* SkFontMgr::Factory() { 2312 SkFontMgr* SkFontMgr::Factory() {
2317 return SkNEW(SkFontMgr_Mac); 2313 return SkNEW(SkFontMgr_Mac);
2318 } 2314 }
2319 #endif 2315 #endif
OLDNEW
« no previous file with comments | « src/ports/SkFontHost_FreeType.cpp ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698