MCPcopy Create free account
hub / github.com/Tencent/tgfx / Shape

Method Shape

test/src/utils/TextShaper.cpp:248–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248PositionedGlyphs TextShaper::Shape(const std::string& text, std::shared_ptr<Typeface> face) {
249 std::list<HBGlyph> glyphs;
250 glyphs.emplace_back(HBGlyph{text, {}, 0, nullptr});
251 bool allShaped = false;
252 if (face && !face->fontFamily().empty()) {
253 allShaped = ShapeText(glyphs, std::move(face));
254 }
255 if (!allShaped) {
256 static auto fallbackTypefaces = GetFallbackTypefaces();
257 for (const auto& typeface : fallbackTypefaces) {
258 if (typeface && ShapeText(glyphs, typeface)) {
259 break;
260 }
261 }
262 }
263 std::vector<std::tuple<std::shared_ptr<Typeface>, GlyphID, uint32_t>> glyphIDs;
264 for (const auto& glyph : glyphs) {
265 glyphIDs.emplace_back(glyph.typeface, glyph.glyphID, glyph.stringIndex);
266 }
267 return PositionedGlyphs(std::move(glyphIDs));
268}
269
270void TextShaper::PurgeCaches() {
271 auto cache = GetHBFontCache();

Callers

nothing calls this directly

Calls 5

ShapeTextFunction · 0.85
PositionedGlyphsClass · 0.85
GetFallbackTypefacesFunction · 0.70
emptyMethod · 0.45
fontFamilyMethod · 0.45

Tested by

no test coverage detected