26 auto& font = run.font();
27 auto typeface = std::make_shared<TypefaceSkia>(font.refTypeface());
29 SkFontMetrics sk_metrics;
30 font.getMetrics(&sk_metrics);
34 metrics.
embolden = font.isEmbolden();
35 metrics.
skewX = font.getSkewX();
36 metrics.
scaleX = font.getScaleX();
38 return Font{std::move(typeface), metrics, alignment};
46 const sk_sp<SkTextBlob>& blob) {
47 bool has_color =
false;
48 std::vector<TextRun> runs;
49 for (SkTextBlobRunIterator run(blob.get()); !run.done(); run.next()) {
50 SkStrikeSpec strikeSpec = SkStrikeSpec::MakeWithNoDevice(run.font());
51 SkBulkGlyphMetricsAndPaths paths{strikeSpec};
52 SkSpan<const SkGlyph*> glyphs =
53 paths.glyphs(SkSpan(run.glyphs(), run.glyphCount()));
55 for (
const auto& glyph : glyphs) {
56 has_color |= glyph->isColor();
60 if (run.font().isSubpixel() && run.font().isBaselineSnap() && !has_color) {
64 switch (run.positioning()) {
65 case SkTextBlobRunIterator::kFull_Positioning: {
66 std::vector<TextRun::GlyphPosition> positions;
67 positions.reserve(run.glyphCount());
68 for (
auto i = 0u;
i < run.glyphCount();
i++) {
70 const SkPoint* glyph_points = run.points();
71 const SkPoint* point = glyph_points +
i;
81 runs.emplace_back(text_run);
89 return std::make_shared<TextFrame>(
90 runs,
ToRect(blob->bounds()), has_color,
92 SkPath path = skia::textlayout::Paragraph::GetPath(blob.get());
94 return fml::Status(fml::StatusCode::kCancelled,
"No path available");
96 SkPath transformed = path.makeTransform(
97 SkMatrix::Translate(blob->bounds().left(), blob->bounds().top()));
Represents a collection of positioned glyphs from a specific font.