Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
paragraph_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_PARAGRAPH_STYLE_H_
18#define LIB_TXT_SRC_PARAGRAPH_STYLE_H_
19
20#include <climits>
21#include <string>
22
23#include "font_style.h"
24#include "font_weight.h"
25#include "text_style.h"
26
27namespace txt {
28
29enum class TextAlign {
30 left,
31 right,
32 center,
33 justify,
34 start,
35 end,
36};
37
38enum class TextDirection {
39 rtl,
40 ltr,
41};
42
43// Adjusts the leading over and under text.
44//
45// kDisableFirstAscent and kDisableLastDescent allow disabling height
46// adjustments to first line's ascent and the last line's descent. If disabled,
47// the line will use the default font metric provided ascent/descent and
48// ParagraphStyle.height or TextStyle.height will not take effect.
49//
50// The default behavior is kAll where height adjustments are enabled for all
51// lines.
52//
53// Multiple behaviors can be applied at once with a bitwise | operator. For
54// example, disabling first ascent and last descent can achieved with:
55//
56// (kDisableFirstAscent | kDisableLastDescent).
63
65 public:
66 // Default TextStyle. Used in GetTextStyle() to obtain the base TextStyle to
67 // inherit off of.
70 std::string font_family = "";
71 double font_size = 14;
72 double height = 1;
73 bool has_height_override = false;
75
76 // Strut properties. strut_enabled must be set to true for the rest of the
77 // properties to take effect.
78 // TODO(garyq): Break the strut properties into a separate class.
79 bool strut_enabled = false;
82 std::vector<std::string> strut_font_families;
83 double strut_font_size = 14;
84 double strut_height = 1;
86 bool strut_half_leading = false;
87 double strut_leading = -1; // Negative to use font's default leading. [0,inf)
88 // to use custom leading as a ratio of font size.
89 bool force_strut_height = false;
90
91 // General paragraph properties.
94 size_t max_lines = std::numeric_limits<size_t>::max();
95 std::u16string ellipsis;
96 std::string locale;
97
98 TextStyle GetTextStyle() const;
99
100 bool unlimited_lines() const;
101 bool ellipsized() const;
102
103 // Return a text alignment value that is not dependent on the text direction.
105};
106
107} // namespace txt
108
109#endif // LIB_TXT_SRC_PARAGRAPH_STYLE_H_
std::u16string ellipsis
TextDirection text_direction
FontWeight strut_font_weight
TextStyle GetTextStyle() const
std::vector< std::string > strut_font_families
TextAlign effective_align() const
bool unlimited_lines() const
TextHeightBehavior
@ kDisableAll
@ kDisableLastDescent
@ kDisableFirstAscent
FontWeight
Definition font_weight.h:22
FontStyle
Definition font_style.h:22