41 GetSkFontStyleWeight(font_weight), SkFontStyle::Width::kNormal_Width,
43 : SkFontStyle::Slant::kItalic_Slant);
50 std::shared_ptr<FontCollection> font_collection,
51 const bool impeller_enabled)
52 : base_style_(style.GetTextStyle()), impeller_enabled_(impeller_enabled) {
55 font_collection->CreateSktFontCollection(),
62 builder_->pushStyle(TxtToSkia(style));
63 txt_style_stack_.push(style);
68 txt_style_stack_.pop();
72 return txt_style_stack_.empty() ? base_style_ : txt_style_stack_.top();
76 builder_->addText(
text);
88 builder_->addPlaceholder(placeholder_style);
92 return std::make_unique<ParagraphSkia>(
93 builder_->Build(), std::move(dl_paints_), impeller_enabled_);
98 dl_paints_.push_back(dl_paint);
99 return dl_paints_.size() - 1;
117 skia.setTextStyle(text_style);
121 MakeSkFontStyle(
txt.strut_font_weight,
txt.strut_font_style));
127 std::vector<SkString> strut_fonts;
129 std::back_inserter(strut_fonts),
130 [](
const std::string&
f) { return SkString(f.c_str()); });
135 skia.setStrutStyle(strut_style);
139 skia.setMaxLines(
txt.max_lines);
140 skia.setEllipsis(
txt.ellipsis);
141 skia.setTextHeightBehavior(
144 skia.turnHintingOff();
145 skia.setReplaceTabCharacters(
true);
146 skia.setApplyRoundingHack(
false);
156 skia.setDecorationColor(
txt.decoration_color);
157 skia.setDecorationStyle(
159 skia.setDecorationThicknessMultiplier(
161 skia.setFontStyle(MakeSkFontStyle(
txt.font_weight,
txt.font_style));
164 std::vector<SkString> skia_fonts;
166 std::back_inserter(skia_fonts),
167 [](
const std::string&
f) { return SkString(f.c_str()); });
168 skia.setFontFamilies(skia_fonts);
174 skia.setHeightOverride(
txt.has_height_override);
175 skia.setHalfLeading(
txt.half_leading);
178 if (
txt.background.has_value()) {
179 skia.setBackgroundPaintID(CreatePaintID(
txt.background.
value()));
181 if (
txt.foreground.has_value()) {
182 skia.setForegroundPaintID(CreatePaintID(
txt.foreground.
value()));
186 skia.setForegroundPaintID(CreatePaintID(dl_paint));
189 skia.resetFontFeatures();
190 for (
const auto& ff :
txt.font_features.GetFontFeatures()) {
191 skia.addFontFeature(
SkString(ff.first.c_str()), ff.second);
194 if (!
txt.font_variations.GetAxisValues().empty()) {
195 std::vector<SkFontArguments::VariationPosition::Coordinate> coordinates;
196 for (
const auto& it :
txt.font_variations.GetAxisValues()) {
197 const std::string& axis = it.first;
198 if (axis.length() != 4) {
201 coordinates.push_back({
207 coordinates.data(),
static_cast<int>(coordinates.size())};
208 skia.setFontArguments(
218 skia.addShadow(shadow);
#define SkDoubleToScalar(x)
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
DlPaint & setColor(DlColor color)
static std::unique_ptr< ParagraphBuilder > make(const ParagraphStyle &style, sk_sp< FontCollection > fontCollection, sk_sp< SkUnicode > unicode)
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)
virtual const TextStyle & PeekStyle() override
ParagraphBuilderSkia(const ParagraphStyle &style, std::shared_ptr< FontCollection > font_collection, const bool impeller_enabled)
virtual void PushStyle(const TextStyle &style) override
virtual std::unique_ptr< Paragraph > Build() override
virtual void AddText(const std::u16string &text) override
virtual void AddPlaceholder(PlaceholderRun &span) override
virtual void Pop() override
virtual ~ParagraphBuilderSkia()
PlaceholderAlignment alignment
SKUNICODE_API sk_sp< SkUnicode > Make()
PlaceholderAlignment
Where to vertically align the placeholder relative to the surrounding text.
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
SkFontArguments & setVariationDesignPosition(VariationPosition position)
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)