Flutter Engine
The Flutter Engine
text_run.cc
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
6
7namespace impeller {
8
9TextRun::TextRun(const Font& font) : font_(font) {
10 if (!font_.IsValid()) {
11 return;
12 }
13 is_valid_ = true;
14}
15
16TextRun::TextRun(const Font& font, std::vector<GlyphPosition>& glyphs)
17 : font_(font), glyphs_(std::move(glyphs)) {
18 if (!font_.IsValid()) {
19 return;
20 }
21 is_valid_ = true;
22}
23
24TextRun::~TextRun() = default;
25
26bool TextRun::AddGlyph(Glyph glyph, Point position) {
27 glyphs_.emplace_back(GlyphPosition{glyph, position});
28 return true;
29}
30
31bool TextRun::IsValid() const {
32 return is_valid_;
33}
34
35const std::vector<TextRun::GlyphPosition>& TextRun::GetGlyphPositions() const {
36 return glyphs_;
37}
38
39size_t TextRun::GetGlyphCount() const {
40 return glyphs_.size();
41}
42
43const Font& TextRun::GetFont() const {
44 return font_;
45}
46
47} // namespace impeller
uint16_t glyphs[5]
Definition: FontMgrTest.cpp:46
Describes a typeface along with any modifications to its intrinsic properties.
Definition: font.h:35
bool IsValid() const
Definition: font.cc:23
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.
Definition: ref_ptr.h:256
The glyph index in the typeface.
Definition: glyph.h:16