Flutter Engine
 
Loading...
Searching...
No Matches
paragraph_style.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
8
9namespace impeller::interop {
10
12
14
16 style_.font_weight = weight;
17}
18
20 style_.font_style = style;
21}
22
23void ParagraphStyle::SetFontFamily(std::string family) {
24 style_.font_family = std::move(family);
25}
26
27void ParagraphStyle::SetFontSize(double size) {
28 style_.font_size = size;
29}
30
32 style_.height = height;
33 style_.has_height_override = (height != 0.0);
34}
35
37 style_.text_align = alignment;
38}
39
41 style_.text_direction = direction;
42}
43
44void ParagraphStyle::SetMaxLines(size_t max_lines) {
45 style_.max_lines = max_lines;
46}
47
48void ParagraphStyle::SetLocale(std::string locale) {
49 style_.locale = std::move(locale);
50}
51
53 foreground_ = std::move(paint);
54}
55
57 background_ = std::move(paint);
58}
59
61 auto style = style_.GetTextStyle();
62
63 if (foreground_) {
64 style.foreground = foreground_->GetPaint();
65 }
66 if (background_) {
67 style.background = background_->GetPaint();
68 }
69 if (decoration_.has_value()) {
70 const auto& decoration = decoration_.value();
71 style.decoration = decoration.types;
72 style.decoration_color = ToSkiaType(decoration.color);
73 style.decoration_style = ToTxtType(decoration.style);
74 style.decoration_thickness_multiplier = decoration.thickness_multiplier;
75 }
76
77 return style;
78}
79
81 return style_;
82}
83
85 const ImpellerTextDecoration& decoration) {
86 decoration_ = decoration;
87}
88
89void ParagraphStyle::SetEllipsis(const std::string& string) {
90 if (string.empty()) {
91 style_.ellipsis = {};
92 return;
93 }
94 style_.ellipsis = fml::Utf8ToUtf16(string);
95}
96
97} // namespace impeller::interop
void SetFontFamily(std::string family)
void SetTextDecoration(const ImpellerTextDecoration &decoration)
void SetTextDirection(txt::TextDirection direction)
void SetBackground(ScopedObject< Paint > paint)
void SetForeground(ScopedObject< Paint > paint)
txt::TextStyle CreateTextStyle() const
void SetLocale(std::string locale)
void SetFontStyle(txt::FontStyle style)
void SetEllipsis(const std::string &string)
const txt::ParagraphStyle & GetParagraphStyle() const
void SetMaxLines(size_t max_lines)
void SetTextAlignment(txt::TextAlign alignment)
std::u16string ellipsis
TextDirection text_direction
TextStyle GetTextStyle() const
std::optional< flutter::DlPaint > foreground
Definition text_style.h:48
std::u16string Utf8ToUtf16(const std::string_view string)
constexpr txt::TextDecorationStyle ToTxtType(ImpellerTextDecorationStyle style)
Definition formats.h:442
constexpr std::optional< SkRect > ToSkiaType(const ImpellerRect *rect)
Definition formats.h:30
FontStyle
Definition font_style.h:10
int32_t height