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

Unified Diff: src/ports/SkFontHost_mac.cpp

Issue 1955053002: SkAdvancedTypefaceMetrics: getAdvanceData uses std::function (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typedef Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ports/SkFontHost_FreeType.cpp ('k') | src/ports/SkFontHost_win.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_mac.cpp
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index dc1333173597abdeebf8b56ee4a04cc6d8e3f790..cff69b315cc0254a8d275249aaa8e9a500c4895b 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -1512,15 +1512,6 @@ static void populate_glyph_to_unicode(CTFontRef ctFont, CFIndex glyphCount,
}
}
-static bool getWidthAdvance(CTFontRef ctFont, int gId, int16_t* data) {
- CGSize advance;
- advance.width = 0;
- CGGlyph glyph = gId;
- CTFontGetAdvancesForGlyphs(ctFont, kCTFontHorizontalOrientation, &glyph, &advance, 1);
- *data = sk_float_round2int(advance.width);
- return true;
-}
-
/** Assumes src and dst are not nullptr. */
static void CFStringToSkString(CFStringRef src, SkString* dst) {
// Reserve enough room for the worst-case string,
@@ -1625,8 +1616,20 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
&range, 0, SkAdvancedTypefaceMetrics::WidthRange::kDefault);
info->fGlyphWidths.emplace_back(std::move(range));
} else {
- info->setGlyphWidths(ctFont.get(), SkToInt(glyphCount), glyphIDs,
- glyphIDsCount, &getWidthAdvance);
+ CTFontRef borrowedCTFont = ctFont.get();
+ info->setGlyphWidths(
+ SkToInt(glyphCount), glyphIDs, glyphIDsCount,
+ SkAdvancedTypefaceMetrics::GetAdvance(
+ [borrowedCTFont](int gId, int16_t* data) {
+ CGSize advance;
+ advance.width = 0;
+ CGGlyph glyph = gId;
+ CTFontGetAdvancesForGlyphs(
+ borrowedCTFont, kCTFontHorizontalOrientation,
+ &glyph, &advance, 1);
+ *data = sk_float_round2int(advance.width);
+ return true;
+ }));
}
}
return info;
« 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