49 std::shared_ptr<FontCollection> font_collection,
50 const bool impeller_enabled)
51 : base_style_(style.GetTextStyle()), impeller_enabled_(impeller_enabled) {
52 builder_ = skt::ParagraphBuilder::make(
53 TxtToSkia(style), font_collection->CreateSktFontCollection());
59 builder_->pushStyle(TxtToSkia(style));
60 txt_style_stack_.push(style);
65 txt_style_stack_.pop();
69 return txt_style_stack_.empty() ? base_style_ : txt_style_stack_.top();
73 builder_->addText(
text);
85 builder_->addPlaceholder(placeholder_style);
89 return std::make_unique<ParagraphSkia>(
90 builder_->Build(), std::move(dl_paints_), impeller_enabled_);
93skt::ParagraphPainter::PaintID ParagraphBuilderSkia::CreatePaintID(
95 dl_paints_.push_back(dl_paint);
96 return dl_paints_.size() - 1;
114 skia.setTextStyle(text_style);
118 MakeSkFontStyle(
txt.strut_font_weight,
txt.strut_font_style));
124 std::vector<SkString> strut_fonts;
125 std::transform(
txt.strut_font_families.begin(),
txt.strut_font_families.end(),
126 std::back_inserter(strut_fonts),
127 [](
const std::string& f) { return SkString(f.c_str()); });
132 skia.setStrutStyle(strut_style);
136 skia.setMaxLines(
txt.max_lines);
137 skia.setEllipsis(
txt.ellipsis);
138 skia.setTextHeightBehavior(
141 skia.turnHintingOff();
142 skia.setReplaceTabCharacters(
true);
143 skia.setApplyRoundingHack(
false);
153 skia.setDecorationColor(
txt.decoration_color);
154 skia.setDecorationStyle(
156 skia.setDecorationThicknessMultiplier(
158 skia.setFontStyle(MakeSkFontStyle(
txt.font_weight,
txt.font_style));
161 std::vector<SkString> skia_fonts;
162 std::transform(
txt.font_families.begin(),
txt.font_families.end(),
163 std::back_inserter(skia_fonts),
164 [](
const std::string& f) { return SkString(f.c_str()); });
165 skia.setFontFamilies(skia_fonts);
171 skia.setHeightOverride(
txt.has_height_override);
172 skia.setHalfLeading(
txt.half_leading);
175 if (
txt.background.has_value()) {
176 skia.setBackgroundPaintID(CreatePaintID(
txt.background.
value()));
178 if (
txt.foreground.has_value()) {
179 skia.setForegroundPaintID(CreatePaintID(
txt.foreground.
value()));
183 skia.setForegroundPaintID(CreatePaintID(dl_paint));
186 skia.resetFontFeatures();
187 for (
const auto& ff :
txt.font_features.GetFontFeatures()) {
188 skia.addFontFeature(
SkString(ff.first.c_str()), ff.second);
191 if (!
txt.font_variations.GetAxisValues().empty()) {
192 std::vector<SkFontArguments::VariationPosition::Coordinate> coordinates;
193 for (
const auto& it :
txt.font_variations.GetAxisValues()) {
194 const std::string& axis = it.first;
195 if (axis.length() != 4) {
198 coordinates.push_back({
204 coordinates.data(),
static_cast<int>(coordinates.size())};
205 skia.setFontArguments(
214 shadow.
fColor = txt_shadow.color;
215 skia.addShadow(shadow);
void setFontFamilies(std::vector< SkString > families)
void setHeight(SkScalar height)
void setHeightOverride(bool heightOverride)
void setFontStyle(SkFontStyle fontStyle)
void setLocale(const SkString &locale)
void setFontSize(SkScalar size)
void setForegroundPaintID(ParagraphPainter::PaintID paintID)
PlaceholderAlignment
Where to vertically align the placeholder relative to the surrounding text.
PlaceholderAlignment fAlignment
void setHalfLeading(bool halfLeading)
void setFontFamilies(std::vector< SkString > families)
void setFontStyle(SkFontStyle fontStyle)
void setHeight(SkScalar height)
void setStrutEnabled(bool v)
void setForceStrutHeight(bool v)
void setHeightOverride(bool v)
void setLeading(SkScalar Leading)
void setFontSize(SkScalar size)