9 #include "flutter/fml/logging.h"
13 #include "third_party/skia/include/core/SkFont.h"
14 #include "third_party/skia/include/core/SkFontMetrics.h"
15 #include "third_party/skia/include/core/SkPaint.h"
16 #include "third_party/skia/include/core/SkRect.h"
17 #include "third_party/skia/src/core/SkStrikeSpec.h"
18 #include "third_party/skia/src/core/SkTextBlobPriv.h"
28 case SkAxisAlignment::kNone:
33 case SkAxisAlignment::kX:
35 case SkAxisAlignment::kY:
42 auto& font = run.font();
43 auto typeface = std::make_shared<TypefaceSkia>(font.refTypeface());
45 SkFontMetrics sk_metrics;
46 font.getMetrics(&sk_metrics);
50 metrics.
embolden = font.isEmbolden();
51 metrics.
skewX = font.getSkewX();
52 metrics.
scaleX = font.getScaleX();
54 return Font{std::move(typeface), metrics, alignment};
58 return Rect::MakeLTRB(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
62 const sk_sp<SkTextBlob>& blob) {
63 bool has_color =
false;
64 std::vector<TextRun> runs;
65 for (SkTextBlobRunIterator run(blob.get()); !run.done(); run.next()) {
68 SkStrikeSpec strikeSpec = SkStrikeSpec::MakeWithNoDevice(run.font());
69 SkBulkGlyphMetricsAndPaths paths{strikeSpec};
71 if (run.font().isSubpixel()) {
73 strikeSpec.createScalerContext()->computeAxisAlignmentForHText());
76 const auto glyph_count = run.glyphCount();
77 const auto* glyphs = run.glyphs();
78 switch (run.positioning()) {
79 case SkTextBlobRunIterator::kFull_Positioning: {
80 std::vector<TextRun::GlyphPosition> positions;
81 positions.reserve(glyph_count);
82 for (
auto i = 0u; i < glyph_count; i++) {
84 const SkPoint* glyph_points = run.points();
85 const SkPoint* point = glyph_points + i;
90 positions.emplace_back(
97 runs.emplace_back(text_run);
101 FML_DLOG(ERROR) <<
"Unimplemented.";
105 return std::make_shared<TextFrame>(runs,
ToRect(blob->bounds()), has_color);