Flutter Engine
text_style.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIB_TXT_SRC_TEXT_STYLE_H_
18 #define LIB_TXT_SRC_TEXT_STYLE_H_
19 
20 #include <string>
21 #include <vector>
22 
23 #include "font_features.h"
24 #include "font_style.h"
25 #include "font_weight.h"
26 #include "text_baseline.h"
27 #include "text_decoration.h"
28 #include "text_shadow.h"
29 #include "third_party/skia/include/core/SkColor.h"
30 #include "third_party/skia/include/core/SkPaint.h"
31 
32 namespace txt {
33 
34 class TextStyle {
35  public:
36  SkColor color = SK_ColorWHITE;
38  // Does not make sense to draw a transparent object, so we use it as a default
39  // value to indicate no decoration color was set.
40  SkColor decoration_color = SK_ColorTRANSPARENT;
42  // Thickness is applied as a multiplier to the default thickness of the font.
47  // An ordered list of fonts in order of priority. The first font is more
48  // highly preferred than the last font.
49  std::vector<std::string> font_families;
50  double font_size = 14.0;
51  double letter_spacing = 0.0;
52  double word_spacing = 0.0;
53  double height = 1.0;
54  bool has_height_override = false;
55  std::string locale;
56  bool has_background = false;
57  SkPaint background;
58  bool has_foreground = false;
59  SkPaint foreground;
60  // An ordered list of shadows where the first shadow will be drawn first (at
61  // the bottom).
62  std::vector<TextShadow> text_shadows;
64 
65  TextStyle();
66 
67  bool equals(const TextStyle& other) const;
68 };
69 
70 } // namespace txt
71 
72 #endif // LIB_TXT_SRC_TEXT_STYLE_H_
bool has_background
Definition: text_style.h:56
FontStyle
Definition: font_style.h:22
std::vector< TextShadow > text_shadows
Definition: text_style.h:62
TextDecorationStyle
bool has_height_override
Definition: text_style.h:54
double height
Definition: text_style.h:53
double decoration_thickness_multiplier
Definition: text_style.h:43
FontStyle font_style
Definition: text_style.h:45
FontWeight
Definition: font_weight.h:22
double letter_spacing
Definition: text_style.h:51
std::string locale
Definition: text_style.h:55
double font_size
Definition: text_style.h:50
bool equals(const TextStyle &other) const
Definition: text_style.cc:28
FontFeatures font_features
Definition: text_style.h:63
double word_spacing
Definition: text_style.h:52
SkColor decoration_color
Definition: text_style.h:40
TextDecorationStyle decoration_style
Definition: text_style.h:41
std::vector< std::string > font_families
Definition: text_style.h:49
SkColor color
Definition: text_style.h:36
bool has_foreground
Definition: text_style.h:58
SkPaint foreground
Definition: text_style.h:59
TextBaseline
Definition: text_baseline.h:22
FontWeight font_weight
Definition: text_style.h:44
TextBaseline text_baseline
Definition: text_style.h:46
SkPaint background
Definition: text_style.h:57