| Flutter Impeller |

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
5 #include "impeller/typographer/text_run.h"
6
7 namespace impeller {
8
9 TextRun::TextRun(const Font& font) : font_(font) {
10 if (!font_.IsValid()) {
11 return;
12 }
13 is_valid_ = true;
14 }
15
16 TextRun::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
24 TextRun::~TextRun() = default;
25
26 bool TextRun::AddGlyph(Glyph glyph, Point position) {
27 glyphs_.emplace_back(GlyphPosition{glyph, position});
28 return true;
29 }
30
31 bool TextRun::IsValid() const {
32 return is_valid_;
33 }
34
35 const std::vector<TextRun::GlyphPosition>& TextRun::GetGlyphPositions() const {
36 return glyphs_;
37 }
38
39 size_t TextRun::GetGlyphCount() const {
40 return glyphs_.size();
41 }
42
43 const Font& TextRun::GetFont() const {
44 return font_;
45 }
46
47 } // namespace impeller
impeller::Font
Describes a typeface along with any modifications to its intrinsic properties.
Definition: font.h:21
impeller::Font::IsValid
bool IsValid() const
Definition: font.cc:19
impeller::TextRun::GetFont
const Font & GetFont() const
Get the font for this run.
Definition: text_run.cc:43
impeller::Glyph
The glyph index in the typeface.
Definition: glyph.h:19
impeller::TextRun::TextRun
TextRun(const Font &font)
Create an empty text run with the specified font.
Definition: text_run.cc:9
impeller::TextRun::~TextRun
~TextRun()
impeller::TextRun::AddGlyph
bool AddGlyph(Glyph glyph, Point position)
Add a glyph at the specified position to the run.
Definition: text_run.cc:26
text_run.h
impeller::TextRun::GetGlyphCount
size_t GetGlyphCount() const
Get the number of glyphs in the run.
Definition: text_run.cc:39
std
Definition: comparable.h:98
impeller::TPoint< Scalar >
impeller::TextRun::GlyphPosition
Definition: text_run.h:21
impeller::TextRun::IsValid
bool IsValid() const
Definition: text_run.cc:31
impeller::TextRun::GetGlyphPositions
const std::vector< GlyphPosition > & GetGlyphPositions() const
Get a reference to all the glyph positions within the run.
Definition: text_run.cc:35
impeller
Definition: aiks_context.cc:10