| 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
5 #include "impeller/toolkit/interop/paragraph_style.h"
6
7 namespace impeller::interop {
8
9 ParagraphStyle::ParagraphStyle() = default;
10
11 ParagraphStyle::~ParagraphStyle() = default;
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
50 void ParagraphStyle::SetForeground(ScopedObject<Paint> paint) {
51 foreground_ = std::move(paint);
52 }
53
54 void ParagraphStyle::SetBackground(ScopedObject<Paint> paint) {
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
impeller::interop::ParagraphStyle::~ParagraphStyle
~ParagraphStyle() override
impeller::interop::ParagraphStyle::SetFontWeight
void SetFontWeight(txt::FontWeight weight)
Definition: paragraph_style.cc:13
impeller::interop::ParagraphStyle::SetFontFamily
void SetFontFamily(std::string family)
Definition: paragraph_style.cc:21
impeller::interop::ParagraphStyle::SetTextDirection
void SetTextDirection(txt::TextDirection direction)
Definition: paragraph_style.cc:38
impeller::interop::ParagraphStyle::SetHeight
void SetHeight(double height)
Definition: paragraph_style.cc:29
impeller::interop::ParagraphStyle::SetBackground
void SetBackground(ScopedObject< Paint > paint)
Definition: paragraph_style.cc:54
impeller::interop::ParagraphStyle::SetForeground
void SetForeground(ScopedObject< Paint > paint)
Definition: paragraph_style.cc:50
impeller::interop::ParagraphStyle::CreateTextStyle
txt::TextStyle CreateTextStyle() const
Definition: paragraph_style.cc:58
impeller::interop::ParagraphStyle::SetLocale
void SetLocale(std::string locale)
Definition: paragraph_style.cc:46
impeller::interop::ParagraphStyle::ParagraphStyle
ParagraphStyle()
impeller::interop::ParagraphStyle::SetFontSize
void SetFontSize(double size)
Definition: paragraph_style.cc:25
impeller::interop::ParagraphStyle::SetFontStyle
void SetFontStyle(txt::FontStyle style)
Definition: paragraph_style.cc:17
impeller::interop::ParagraphStyle::GetParagraphStyle
const txt::ParagraphStyle & GetParagraphStyle() const
Definition: paragraph_style.cc:70
impeller::interop::ParagraphStyle::SetMaxLines
void SetMaxLines(size_t max_lines)
Definition: paragraph_style.cc:42
impeller::interop::ParagraphStyle::SetTextAlignment
void SetTextAlignment(txt::TextAlign alignment)
Definition: paragraph_style.cc:34
impeller::interop::ScopedObject
Definition: object.h:67
impeller::interop
Definition: color_filter.cc:7
paragraph_style.h