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 2222523003: SkPDF/SkAdvancedTypefaceMetrics: simplify ATM, PDF takes over (Closed) Base URL: https://skia.googlesource.com/skia.git@SkPDF_no_kHAdvance
Patch Set: rebase and nit Created 4 years, 4 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 * 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 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 CTFontGetBoundingRectsForGlyphs(ctFont, kCTFontHorizontalOrientation, 1660 CTFontGetBoundingRectsForGlyphs(ctFont, kCTFontHorizontalOrientation,
1661 glyphs, boundingRects, count); 1661 glyphs, boundingRects, count);
1662 for (size_t i = 0; i < count; i++) { 1662 for (size_t i = 0; i < count; i++) {
1663 int16_t width = (int16_t) boundingRects[i].size.width; 1663 int16_t width = (int16_t) boundingRects[i].size.width;
1664 if (width > 0 && width < min_width) { 1664 if (width > 0 && width < min_width) {
1665 min_width = width; 1665 min_width = width;
1666 info->fStemV = min_width; 1666 info->fStemV = min_width;
1667 } 1667 }
1668 } 1668 }
1669 } 1669 }
1670
1671 if (perGlyphInfo & kHAdvance_PerGlyphInfo) {
1672 CTFontRef borrowedCTFont = ctFont.get();
1673 info->setGlyphWidths(
1674 SkToInt(glyphCount),
1675 glyphIDs,
1676 glyphIDsCount,
1677 SkAdvancedTypefaceMetrics::GetAdvance([borrowedCTFont](int gId, int1 6_t* data) {
1678 CGSize advance;
1679 advance.width = 0;
1680 CGGlyph glyph = gId;
1681 CTFontGetAdvancesForGlyphs(borrowedCTFont, kCTFontHorizontalOrie ntation,
1682 &glyph, &advance, 1);
1683 *data = sk_float_round2int(advance.width);
1684 return true;
1685 })
1686 );
1687 }
1688 return info; 1670 return info;
1689 } 1671 }
1690 1672
1691 /////////////////////////////////////////////////////////////////////////////// 1673 ///////////////////////////////////////////////////////////////////////////////
1692 1674
1693 static SK_SFNT_ULONG get_font_type_tag(const SkTypeface_Mac* typeface) { 1675 static SK_SFNT_ULONG get_font_type_tag(const SkTypeface_Mac* typeface) {
1694 CTFontRef ctFont = typeface->fFontRef.get(); 1676 CTFontRef ctFont = typeface->fFontRef.get();
1695 AutoCFRelease<CFNumberRef> fontFormatRef( 1677 AutoCFRelease<CFNumberRef> fontFormatRef(
1696 static_cast<CFNumberRef>(CTFontCopyAttribute(ctFont, kCTFontFormatAt tribute))); 1678 static_cast<CFNumberRef>(CTFontCopyAttribute(ctFont, kCTFontFormatAt tribute)));
1697 if (!fontFormatRef) { 1679 if (!fontFormatRef) {
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 2611
2630 return SkSafeRef(GetDefaultFace()); 2612 return SkSafeRef(GetDefaultFace());
2631 } 2613 }
2632 }; 2614 };
2633 2615
2634 /////////////////////////////////////////////////////////////////////////////// 2616 ///////////////////////////////////////////////////////////////////////////////
2635 2617
2636 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; } 2618 SkFontMgr* SkFontMgr::Factory() { return new SkFontMgr_Mac; }
2637 2619
2638 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) 2620 #endif//defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
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