Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 <optional>
21#include <string>
22#include <vector>
23
24#include "flutter/display_list/dl_paint.h"
25#include "font_features.h"
26#include "font_style.h"
27#include "font_weight.h"
28#include "text_baseline.h"
29#include "text_decoration.h"
30#include "text_shadow.h"
33
34namespace txt {
35
36class TextStyle {
37 public:
40 // Does not make sense to draw a transparent object, so we use it as a default
41 // value to indicate no decoration color was set.
44 // Thickness is applied as a multiplier to the default thickness of the font.
49 bool half_leading = false;
50 // An ordered list of fonts in order of priority. The first font is more
51 // highly preferred than the last font.
52 std::vector<std::string> font_families;
53 double font_size = 14.0;
54 double letter_spacing = 0.0;
55 double word_spacing = 0.0;
56 double height = 1.0;
57 bool has_height_override = false;
58 std::string locale;
59 std::optional<flutter::DlPaint> background;
60 std::optional<flutter::DlPaint> foreground;
61 // An ordered list of shadows where the first shadow will be drawn first (at
62 // the bottom).
63 std::vector<TextShadow> text_shadows;
66
67 TextStyle();
68
69 bool equals(const TextStyle& other) const;
70};
71
72} // namespace txt
73
74#endif // LIB_TXT_SRC_TEXT_STYLE_H_
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorTRANSPARENT
Definition SkColor.h:99
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122
std::vector< std::string > font_families
Definition text_style.h:52
std::optional< flutter::DlPaint > foreground
Definition text_style.h:60
TextDecorationStyle decoration_style
Definition text_style.h:43
FontStyle font_style
Definition text_style.h:47
SkColor decoration_color
Definition text_style.h:42
double word_spacing
Definition text_style.h:55
FontFeatures font_features
Definition text_style.h:64
FontVariations font_variations
Definition text_style.h:65
bool has_height_override
Definition text_style.h:57
bool equals(const TextStyle &other) const
Definition text_style.cc:28
std::vector< TextShadow > text_shadows
Definition text_style.h:63
double font_size
Definition text_style.h:53
std::string locale
Definition text_style.h:58
SkColor color
Definition text_style.h:38
double decoration_thickness_multiplier
Definition text_style.h:45
FontWeight font_weight
Definition text_style.h:46
TextBaseline text_baseline
Definition text_style.h:48
std::optional< flutter::DlPaint > background
Definition text_style.h:59
double letter_spacing
Definition text_style.h:54
FontWeight
Definition font_weight.h:22
FontStyle
Definition font_style.h:22
TextDecorationStyle
@ kAlphabetic