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

Unified Diff: src/ports/SkFontHost_FreeType.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/core/SkAdvancedTypefaceMetrics.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_FreeType.cpp
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 30e5fb340f4ddeb154b42a1e1e77da71ae7f3ddb..4dc401c59a6f456aaf360d3ef90de6b0174a733c 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -432,16 +432,6 @@ static bool GetLetterCBox(FT_Face face, char letter, FT_BBox* bbox) {
return true;
}
-static bool getWidthAdvance(FT_Face face, int gId, int16_t* data) {
- FT_Fixed advance = 0;
- if (FT_Get_Advances(face, gId, 1, FT_LOAD_NO_SCALE, &advance)) {
- return false;
- }
- SkASSERT(data);
- *data = advance;
- return true;
-}
-
static void populate_glyph_to_unicode(FT_Face& face, SkTDArray<SkUnichar>* glyphToUnicode) {
FT_Long numGlyphs = face->num_glyphs;
glyphToUnicode->setCount(SkToInt(numGlyphs));
@@ -615,8 +605,19 @@ SkAdvancedTypefaceMetrics* SkTypeface_FreeType::onGetAdvancedTypefaceMetrics(
SkAdvancedTypefaceMetrics::WidthRange::kRange);
info->fGlyphWidths.emplace_back(std::move(range));
} else {
- info->setGlyphWidths(face, face->num_glyphs, glyphIDs,
- glyphIDsCount, &getWidthAdvance);
+ info->setGlyphWidths(
+ face->num_glyphs, glyphIDs, glyphIDsCount,
+ SkAdvancedTypefaceMetrics::GetAdvance(
+ [face](int gId, int16_t* data) {
+ FT_Fixed advance = 0;
+ if (FT_Get_Advances(face, gId, 1,
+ FT_LOAD_NO_SCALE, &advance)) {
+ return false;
+ }
+ SkASSERT(data);
+ *data = advance;
+ return true;
+ }));
}
}
« no previous file with comments | « src/core/SkAdvancedTypefaceMetrics.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698