Flutter Engine
The Flutter Engine
text_frame.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_IMPELLER_TYPOGRAPHER_TEXT_FRAME_H_
6#define FLUTTER_IMPELLER_TYPOGRAPHER_TEXT_FRAME_H_
7
10
11namespace impeller {
12
13//------------------------------------------------------------------------------
14/// @brief Represents a collection of shaped text runs.
15///
16/// This object is typically the entrypoint in the Impeller type
17/// rendering subsystem.
18///
19class TextFrame {
20 public:
22
23 TextFrame(std::vector<TextRun>& runs, Rect bounds, bool has_color);
24
26
30 const GlyphProperties& properties) const;
31
33 const TextRun::GlyphPosition& glyph_position,
34 AxisAlignment alignment,
37
38 static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size);
39
40 //----------------------------------------------------------------------------
41 /// @brief The conservative bounding box for this text frame.
42 ///
43 /// @return The bounds rectangle. If there are no glyphs in this text
44 /// frame and empty Rectangle is returned instead.
45 ///
46 Rect GetBounds() const;
47
48 //----------------------------------------------------------------------------
49 /// @brief The number of runs in this text frame.
50 ///
51 /// @return The run count.
52 ///
53 size_t GetRunCount() const;
54
55 //----------------------------------------------------------------------------
56 /// @brief Returns a reference to all the text runs in this frame.
57 ///
58 /// @return The runs in this frame.
59 ///
60 const std::vector<TextRun>& GetRuns() const;
61
62 //----------------------------------------------------------------------------
63 /// @brief Returns the paint color this text frame was recorded with.
64 ///
65 /// Non-bitmap/COLR fonts always use a black text color here, but
66 /// COLR fonts can potentially use the paint color in the glyph
67 /// atlas, so this color must be considered as part of the cache
68 /// key.
69 bool HasColor() const;
70
71 //----------------------------------------------------------------------------
72 /// @brief The type of atlas this run should be emplaced in.
74
75 TextFrame& operator=(TextFrame&& other) = default;
76
77 TextFrame(const TextFrame& other) = default;
78
79 private:
80 std::vector<TextRun> runs_;
81 Rect bounds_;
82 bool has_color_;
83};
84
85} // namespace impeller
86
87#endif // FLUTTER_IMPELLER_TYPOGRAPHER_TEXT_FRAME_H_
Type
Describes how the glyphs are represented in the texture.
Definition: glyph_atlas.h:31
Represents a collection of shaped text runs.
Definition: text_frame.h:19
Rect GetBounds() const
The conservative bounding box for this text frame.
Definition: text_frame.cc:18
static Scalar RoundScaledFontSize(Scalar scale, Scalar point_size)
Definition: text_frame.cc:40
GlyphAtlas::Type GetAtlasType() const
The type of atlas this run should be emplaced in.
Definition: text_frame.cc:30
TextFrame & operator=(TextFrame &&other)=default
bool HasColor() const
Returns the paint color this text frame was recorded with.
Definition: text_frame.cc:35
void CollectUniqueFontGlyphPairs(FontGlyphMap &glyph_map, Scalar scale, Point offset, const GlyphProperties &properties) const
Definition: text_frame.cc:87
TextFrame(const TextFrame &other)=default
size_t GetRunCount() const
The number of runs in this text frame.
Definition: text_frame.cc:22
static Point ComputeSubpixelPosition(const TextRun::GlyphPosition &glyph_position, AxisAlignment alignment, Point offset, Scalar scale)
Definition: text_frame.cc:68
const std::vector< TextRun > & GetRuns() const
Returns a reference to all the text runs in this frame.
Definition: text_frame.cc:26
Optional< SkRect > bounds
Definition: SkRecords.h:189
float Scalar
Definition: scalar.h:18
AxisAlignment
Determines the axis along which there is subpixel positioning.
Definition: font.h:20
std::unordered_map< ScaledFont, std::unordered_set< SubpixelGlyph > > FontGlyphMap
const Scalar scale
SeparatedVector2 offset