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