Flutter Impeller
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 
7 namespace impeller::interop {
8 
10 
12 
13 void ParagraphStyle::SetFontWeight(txt::FontWeight weight) {
14  style_.font_weight = weight;
15 }
16 
17 void ParagraphStyle::SetFontStyle(txt::FontStyle style) {
18  style_.font_style = style;
19 }
20 
21 void ParagraphStyle::SetFontFamily(std::string family) {
22  style_.font_family = std::move(family);
23 }
24 
25 void ParagraphStyle::SetFontSize(double size) {
26  style_.font_size = size;
27 }
28 
29 void ParagraphStyle::SetHeight(double height) {
30  style_.height = height;
31  style_.has_height_override = (height != 0.0);
32 }
33 
34 void ParagraphStyle::SetTextAlignment(txt::TextAlign alignment) {
35  style_.text_align = alignment;
36 }
37 
38 void ParagraphStyle::SetTextDirection(txt::TextDirection direction) {
39  style_.text_direction = direction;
40 }
41 
42 void ParagraphStyle::SetMaxLines(size_t max_lines) {
43  style_.max_lines = max_lines;
44 }
45 
46 void ParagraphStyle::SetLocale(std::string locale) {
47  style_.locale = std::move(locale);
48 }
49 
51  foreground_ = std::move(paint);
52 }
53 
55  background_ = std::move(paint);
56 }
57 
58 txt::TextStyle ParagraphStyle::CreateTextStyle() const {
59  auto style = style_.GetTextStyle();
60 
61  if (foreground_) {
62  style.foreground = foreground_->GetPaint();
63  }
64  if (background_) {
65  style.background = background_->GetPaint();
66  }
67  return style;
68 }
69 
70 const txt::ParagraphStyle& ParagraphStyle::GetParagraphStyle() const {
71  return style_;
72 }
73 
74 } // namespace impeller::interop
void SetFontWeight(txt::FontWeight weight)
void SetFontFamily(std::string family)
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)
const txt::ParagraphStyle & GetParagraphStyle() const
void SetMaxLines(size_t max_lines)
void SetTextAlignment(txt::TextAlign alignment)