Flutter Engine
The Flutter Engine
text_run.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_RUN_H_
6#define FLUTTER_IMPELLER_TYPOGRAPHER_TEXT_RUN_H_
7
8#include <vector>
9
13
14namespace impeller {
15
16//------------------------------------------------------------------------------
17/// @brief Represents a collection of positioned glyphs from a specific
18/// font.
19///
20class TextRun {
21 public:
25
26 GlyphPosition(Glyph p_glyph, Point p_position)
27 : glyph(p_glyph), position(p_position) {}
28 };
29
30 //----------------------------------------------------------------------------
31 /// @brief Create an empty text run with the specified font.
32 ///
33 /// @param[in] font The font
34 ///
35 explicit TextRun(const Font& font);
36
37 TextRun(const Font& font, std::vector<GlyphPosition>& glyphs);
38
40
41 bool IsValid() const;
42
43 //----------------------------------------------------------------------------
44 /// @brief Add a glyph at the specified position to the run.
45 ///
46 /// @param[in] glyph The glyph
47 /// @param[in] position The position
48 ///
49 /// @return If the glyph could be added to the run.
50 ///
51 bool AddGlyph(Glyph glyph, Point position);
52
53 //----------------------------------------------------------------------------
54 /// @brief Get the number of glyphs in the run.
55 ///
56 /// @return The glyph count.
57 ///
58 size_t GetGlyphCount() const;
59
60 //----------------------------------------------------------------------------
61 /// @brief Get a reference to all the glyph positions within the run.
62 ///
63 /// @return The glyph positions.
64 ///
65 const std::vector<GlyphPosition>& GetGlyphPositions() const;
66
67 //----------------------------------------------------------------------------
68 /// @brief Get the font for this run.
69 ///
70 /// @return The font.
71 ///
72 const Font& GetFont() const;
73
74 private:
75 Font font_;
76 std::vector<GlyphPosition> glyphs_;
77 bool is_valid_ = false;
78};
79
80} // namespace impeller
81
82#endif // FLUTTER_IMPELLER_TYPOGRAPHER_TEXT_RUN_H_
uint16_t glyphs[5]
Definition: FontMgrTest.cpp:46
Describes a typeface along with any modifications to its intrinsic properties.
Definition: font.h:35
Represents a collection of positioned glyphs from a specific font.
Definition: text_run.h:20
size_t GetGlyphCount() const
Get the number of glyphs in the run.
Definition: text_run.cc:39
bool IsValid() const
Definition: text_run.cc:31
const Font & GetFont() const
Get the font for this run.
Definition: text_run.cc:43
bool AddGlyph(Glyph glyph, Point position)
Add a glyph at the specified position to the run.
Definition: text_run.cc:26
TextRun(const Font &font)
Create an empty text run with the specified font.
Definition: text_run.cc:9
const std::vector< GlyphPosition > & GetGlyphPositions() const
Get a reference to all the glyph positions within the run.
Definition: text_run.cc:35
font
Font Metadata and Metrics.
The glyph index in the typeface.
Definition: glyph.h:16
GlyphPosition(Glyph p_glyph, Point p_position)
Definition: text_run.h:26