 |
Flutter Impeller
|
|
Go to the documentation of this file.
14 atlas_size_(
ISize(0, 0)) {}
32 atlas_ = std::move(atlas);
37 std::shared_ptr<RectanglePacker> rect_packer) {
38 rect_packer_ = std::move(rect_packer);
58 texture_ = std::move(texture);
68 const auto& found = font_atlas_map_.find(pair.
scaled_font);
69 if (found == font_atlas_map_.end()) {
72 return found->second.FindGlyphBounds(pair.
glyph);
77 const auto& found = font_atlas_map_.find({font,
scale});
78 if (found == font_atlas_map_.end()) {
81 return &found->second;
85 return std::accumulate(font_atlas_map_.begin(), font_atlas_map_.end(), 0,
86 [](
const int a,
const auto&
b) {
87 return a + b.second.positions_.size();
92 const std::function<
bool(
const ScaledFont& scaled_font,
94 const Rect& rect)>& iterator)
const {
100 for (
const auto& font_value : font_atlas_map_) {
101 for (
const auto& glyph_value : font_value.second.positions_) {
103 if (!iterator(font_value.first, glyph_value.first, glyph_value.second)) {
112 const auto& found = positions_.find(glyph);
113 if (found == positions_.end()) {
116 return found->second;
size_t GetGlyphCount() const
Get the number of unique font-glyph pairs in this atlas.
std::shared_ptr< RectanglePacker > GetRectPacker() const
Retrieve the previous (if any) rect packer.
Describes a typeface along with any modifications to its intrinsic properties.
std::optional< Rect > FindFontGlyphBounds(const FontGlyphPair &pair) const
Find the location of a specific font-glyph pair in the atlas.
std::shared_ptr< GlyphAtlas > GetGlyphAtlas() const
Retrieve the current glyph atlas.
const FontGlyphAtlas * GetFontGlyphAtlas(const Font &font, Scalar scale) const
Obtain an interface for querying the location of glyphs in the atlas for the given font and scale....
An object that can look up glyph locations within the GlyphAtlas for a particular typeface.
void SetTexture(std::shared_ptr< Texture > texture)
Set the texture for the glyph atlas.
virtual ~GlyphAtlasContext()
size_t IterateGlyphs(const std::function< bool(const ScaledFont &scaled_font, const Glyph &glyph, const Rect &rect)> &iterator) const
Iterate of all the glyphs along with their locations in the atlas.
GlyphAtlas(Type type)
Create an empty glyph atlas.
The glyph index in the typeface.
const ISize & GetAtlasSize() const
Retrieve the size of the current glyph atlas.
const ScaledFont & scaled_font
Type GetType() const
Describes how the glyphs are represented in the texture.
const std::shared_ptr< Texture > & GetTexture() const
Get the texture for the glyph atlas.
Type
Describes how the glyphs are represented in the texture.
void AddTypefaceGlyphPosition(const FontGlyphPair &pair, Rect rect)
Record the location of a specific font-glyph pair within the atlas.
A font along with a glyph in that font rendered at a particular scale.
A texture containing the bitmap representation of glyphs in different fonts along with the ability to...
std::optional< Rect > FindGlyphBounds(const Glyph &glyph) const
Find the location of a glyph in the atlas.
A font and a scale. Used as a key that represents a typeface within a glyph atlas.
void UpdateGlyphAtlas(std::shared_ptr< GlyphAtlas > atlas, ISize size)
Update the context with a newly constructed glyph atlas.
void UpdateRectPacker(std::shared_ptr< RectanglePacker > rect_packer)