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

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

Issue 107863002: [PDF] Fix font embedding restrictions. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix Mac Created 7 years 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 | Annotate | Revision Log
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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
1545 info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag;
1546 info->fStyle = 0;
1546 1547
1547 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) { 1548 if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) {
1548 populate_glyph_to_unicode(ctFont, glyphCount, &info->fGlyphToUnicode); 1549 populate_glyph_to_unicode(ctFont, glyphCount, &info->fGlyphToUnicode);
1549 } 1550 }
1550 1551
1551 info->fStyle = 0;
1552
1553 // If it's not a truetype font, mark it as 'other'. Assume that TrueType 1552 // 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 1553 // 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 1554 // sfntly needs to subset the font. CTFontCopyAttribute() does not always
1556 // succeed in determining this directly. 1555 // succeed in determining this directly.
1557 if (!this->getTableSize('glyf') || !this->getTableSize('loca')) { 1556 if (!this->getTableSize('glyf') || !this->getTableSize('loca')) {
1558 info->fType = SkAdvancedTypefaceMetrics::kOther_Font; 1557 info->fType = SkAdvancedTypefaceMetrics::kOther_Font;
1559 info->fItalicAngle = 0; 1558 info->fItalicAngle = 0;
1560 info->fAscent = 0; 1559 info->fAscent = 0;
1561 info->fDescent = 0; 1560 info->fDescent = 0;
1562 info->fStemV = 0; 1561 info->fStemV = 0;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 glyphs, boundingRects, count); 1605 glyphs, boundingRects, count);
1607 for (size_t i = 0; i < count; i++) { 1606 for (size_t i = 0; i < count; i++) {
1608 int16_t width = (int16_t) boundingRects[i].size.width; 1607 int16_t width = (int16_t) boundingRects[i].size.width;
1609 if (width > 0 && width < min_width) { 1608 if (width > 0 && width < min_width) {
1610 min_width = width; 1609 min_width = width;
1611 info->fStemV = min_width; 1610 info->fStemV = min_width;
1612 } 1611 }
1613 } 1612 }
1614 } 1613 }
1615 1614
1616 if (false) { // TODO: haven't figured out how to know if font is embeddable 1615 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) { 1616 if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) {
1621 skia_advanced_typeface_metrics_utils::appendRange(&info->fGlyphWidth s, 0); 1617 skia_advanced_typeface_metrics_utils::appendRange(&info->fGlyphWidth s, 0);
1622 info->fGlyphWidths->fAdvance.append(1, &min_width); 1618 info->fGlyphWidths->fAdvance.append(1, &min_width);
1623 skia_advanced_typeface_metrics_utils::finishRange(info->fGlyphWidths .get(), 0, 1619 skia_advanced_typeface_metrics_utils::finishRange(info->fGlyphWidths .get(), 0,
1624 SkAdvancedTypefaceMetrics::WidthRange::kDefault); 1620 SkAdvancedTypefaceMetrics::WidthRange::kDefault);
1625 } else { 1621 } else {
1626 info->fGlyphWidths.reset( 1622 info->fGlyphWidths.reset(
1627 skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get( ), 1623 skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get( ),
1628 glyphCount, 1624 glyphCount,
1629 glyphIDs, 1625 glyphIDs,
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits); 2303 return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits);
2308 } 2304 }
2309 }; 2305 };
2310 2306
2311 /////////////////////////////////////////////////////////////////////////////// 2307 ///////////////////////////////////////////////////////////////////////////////
2312 2308
2313 SkFontMgr* SkFontMgr::Factory() { 2309 SkFontMgr* SkFontMgr::Factory() {
2314 return SkNEW(SkFontMgr_Mac); 2310 return SkNEW(SkFontMgr_Mac);
2315 } 2311 }
2316 #endif 2312 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698