Flutter Engine
The Flutter Engine
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ParagraphStyle.h
Go to the documentation of this file.
1// Copyright 2019 Google LLC.
2#ifndef ParagraphStyle_DEFINED
3#define ParagraphStyle_DEFINED
4
10
11#include <stddef.h>
12#include <algorithm>
13#include <limits>
14#include <string>
15#include <utility>
16#include <vector>
17
18namespace skia {
19namespace textlayout {
20
21struct StrutStyle {
22 StrutStyle();
23
24 const std::vector<SkString>& getFontFamilies() const { return fFontFamilies; }
25 void setFontFamilies(std::vector<SkString> families) { fFontFamilies = std::move(families); }
26
27 SkFontStyle getFontStyle() const { return fFontStyle; }
28 void setFontStyle(SkFontStyle fontStyle) { fFontStyle = fontStyle; }
29
30 SkScalar getFontSize() const { return fFontSize; }
31 void setFontSize(SkScalar size) { fFontSize = size; }
32
33 void setHeight(SkScalar height) { fHeight = height; }
34 SkScalar getHeight() const { return fHeight; }
35
36 void setLeading(SkScalar Leading) { fLeading = Leading; }
37 SkScalar getLeading() const { return fLeading; }
38
39 bool getStrutEnabled() const { return fEnabled; }
40 void setStrutEnabled(bool v) { fEnabled = v; }
41
42 bool getForceStrutHeight() const { return fForceHeight; }
43 void setForceStrutHeight(bool v) { fForceHeight = v; }
44
45 bool getHeightOverride() const { return fHeightOverride; }
46 void setHeightOverride(bool v) { fHeightOverride = v; }
47
48 void setHalfLeading(bool halfLeading) { fHalfLeading = halfLeading; }
49 bool getHalfLeading() const { return fHalfLeading; }
50
51 bool operator==(const StrutStyle& rhs) const {
52 return this->fEnabled == rhs.fEnabled &&
53 this->fHeightOverride == rhs.fHeightOverride &&
54 this->fForceHeight == rhs.fForceHeight &&
55 this->fHalfLeading == rhs.fHalfLeading &&
56 nearlyEqual(this->fLeading, rhs.fLeading) &&
57 nearlyEqual(this->fHeight, rhs.fHeight) &&
58 nearlyEqual(this->fFontSize, rhs.fFontSize) &&
59 this->fFontStyle == rhs.fFontStyle &&
60 this->fFontFamilies == rhs.fFontFamilies;
61 }
62
63private:
64
65 std::vector<SkString> fFontFamilies;
66 SkFontStyle fFontStyle;
67 SkScalar fFontSize;
68 SkScalar fHeight;
69 SkScalar fLeading;
70 bool fForceHeight;
71 bool fEnabled;
72 bool fHeightOverride;
73 // true: half leading.
74 // false: scale ascent/descent with fHeight.
75 bool fHalfLeading;
76};
77
80
81 bool operator==(const ParagraphStyle& rhs) const {
82 return this->fHeight == rhs.fHeight &&
83 this->fEllipsis == rhs.fEllipsis &&
84 this->fEllipsisUtf16 == rhs.fEllipsisUtf16 &&
85 this->fTextDirection == rhs.fTextDirection && this->fTextAlign == rhs.fTextAlign &&
86 this->fDefaultTextStyle == rhs.fDefaultTextStyle &&
87 this->fReplaceTabCharacters == rhs.fReplaceTabCharacters;
88 }
89
90 const StrutStyle& getStrutStyle() const { return fStrutStyle; }
91 void setStrutStyle(StrutStyle strutStyle) { fStrutStyle = std::move(strutStyle); }
92
93 const TextStyle& getTextStyle() const { return fDefaultTextStyle; }
94 void setTextStyle(const TextStyle& textStyle) { fDefaultTextStyle = textStyle; }
95
96 TextDirection getTextDirection() const { return fTextDirection; }
97 void setTextDirection(TextDirection direction) { fTextDirection = direction; }
98
99 TextAlign getTextAlign() const { return fTextAlign; }
100 void setTextAlign(TextAlign align) { fTextAlign = align; }
101
102 size_t getMaxLines() const { return fLinesLimit; }
103 void setMaxLines(size_t maxLines) { fLinesLimit = maxLines; }
104
105 SkString getEllipsis() const { return fEllipsis; }
106 std::u16string getEllipsisUtf16() const { return fEllipsisUtf16; }
107 void setEllipsis(const std::u16string& ellipsis) { fEllipsisUtf16 = ellipsis; }
108 void setEllipsis(const SkString& ellipsis) { fEllipsis = ellipsis; }
109
110 SkScalar getHeight() const { return fHeight; }
111 void setHeight(SkScalar height) { fHeight = height; }
112
113 TextHeightBehavior getTextHeightBehavior() const { return fTextHeightBehavior; }
114 void setTextHeightBehavior(TextHeightBehavior v) { fTextHeightBehavior = v; }
115
116 bool unlimited_lines() const {
117 return fLinesLimit == std::numeric_limits<size_t>::max();
118 }
119 bool ellipsized() const { return !fEllipsis.isEmpty() || !fEllipsisUtf16.empty(); }
121 bool hintingIsOn() const { return fHintingIsOn; }
122 void turnHintingOff() { fHintingIsOn = false; }
123
124 bool getReplaceTabCharacters() const { return fReplaceTabCharacters; }
125 void setReplaceTabCharacters(bool value) { fReplaceTabCharacters = value; }
126
127 bool getApplyRoundingHack() const { return fApplyRoundingHack; }
128 void setApplyRoundingHack(bool value) { fApplyRoundingHack = value; }
129
130private:
131 StrutStyle fStrutStyle;
132 TextStyle fDefaultTextStyle;
133 TextAlign fTextAlign;
134 TextDirection fTextDirection;
135 size_t fLinesLimit;
136 std::u16string fEllipsisUtf16;
137 SkString fEllipsis;
138 SkScalar fHeight;
139 TextHeightBehavior fTextHeightBehavior;
140 bool fHintingIsOn;
141 bool fReplaceTabCharacters;
142 bool fApplyRoundingHack = true;
143};
144} // namespace textlayout
145} // namespace skia
146
147#endif // ParagraphStyle_DEFINED
bool isEmpty() const
Definition: SkString.h:130
float SkScalar
Definition: extension.cpp:12
uint8_t value
static float max(float r, float g, float b)
Definition: hsl.cpp:49
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
static bool nearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition: TextStyle.h:31
Definition: DartTypes.h:13
int32_t height
void setEllipsis(const SkString &ellipsis)
std::u16string getEllipsisUtf16() const
void setReplaceTabCharacters(bool value)
bool operator==(const ParagraphStyle &rhs) const
void setEllipsis(const std::u16string &ellipsis)
void setTextDirection(TextDirection direction)
void setTextStyle(const TextStyle &textStyle)
TextHeightBehavior getTextHeightBehavior() const
const StrutStyle & getStrutStyle() const
void setMaxLines(size_t maxLines)
const TextStyle & getTextStyle() const
void setHeight(SkScalar height)
void setStrutStyle(StrutStyle strutStyle)
void setTextHeightBehavior(TextHeightBehavior v)
void setTextAlign(TextAlign align)
TextDirection getTextDirection() const
bool operator==(const StrutStyle &rhs) const
void setHalfLeading(bool halfLeading)
SkScalar getFontSize() const
void setFontFamilies(std::vector< SkString > families)
void setFontStyle(SkFontStyle fontStyle)
void setHeight(SkScalar height)
SkFontStyle getFontStyle() const
void setLeading(SkScalar Leading)
const std::vector< SkString > & getFontFamilies() const
void setFontSize(SkScalar size)