SkAdvancedTypefaceMetrics: getAdvanceData uses std::function
Reduce templatedness.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1955053002
Review-Url: https://codereview.chromium.org/1955053002
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index 30e5fb3..4dc401c 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -432,16 +432,6 @@
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::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;
+ }));
}
}