| 246 | } |
| 247 | |
| 248 | PositionedGlyphs 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 | |
| 270 | void TextShaper::PurgeCaches() { |
| 271 | auto cache = GetHBFontCache(); |
nothing calls this directly
no test coverage detected