A texture containing the bitmap representation of glyphs in different fonts along with the ability to query the location of specific font glyphs within the texture. More...
#include <glyph_atlas.h>
Public Types | |
enum class | Type { kAlphaBitmap , kColorBitmap } |
Describes how the glyphs are represented in the texture. More... | |
Public Member Functions | |
GlyphAtlas (Type type, size_t initial_generation) | |
Create an empty glyph atlas. More... | |
~GlyphAtlas () | |
bool | IsValid () const |
Type | GetType () const |
Describes how the glyphs are represented in the texture. More... | |
void | SetTexture (std::shared_ptr< Texture > texture) |
Set the texture for the glyph atlas. More... | |
const std::shared_ptr< Texture > & | GetTexture () const |
Get the texture for the glyph atlas. More... | |
void | AddTypefaceGlyphPositionAndBounds (const FontGlyphPair &pair, Rect position, Rect bounds) |
Record the location of a specific font-glyph pair within the atlas. More... | |
size_t | GetGlyphCount () const |
Get the number of unique font-glyph pairs in this atlas. More... | |
size_t | IterateGlyphs (const std::function< bool(const ScaledFont &scaled_font, const SubpixelGlyph &glyph, const Rect &rect)> &iterator) const |
Iterate of all the glyphs along with their locations in the atlas. More... | |
std::optional< FrameBounds > | FindFontGlyphBounds (const FontGlyphPair &pair) const |
Find the location of a specific font-glyph pair in the atlas. More... | |
FontGlyphAtlas * | GetOrCreateFontGlyphAtlas (const ScaledFont &scaled_font) |
Obtain an interface for querying the location of glyphs in the atlas for the given font and scale. This provides a more efficient way to look up a run of glyphs in the same font. More... | |
size_t | GetAtlasGeneration () const |
Retrieve the generation id for this glyph atlas. More... | |
void | SetAtlasGeneration (size_t value) |
Update the atlas generation. More... | |
A texture containing the bitmap representation of glyphs in different fonts along with the ability to query the location of specific font glyphs within the texture.
Definition at line 70 of file glyph_atlas.h.
|
strong |
Describes how the glyphs are represented in the texture.
Definition at line 74 of file glyph_atlas.h.
impeller::GlyphAtlas::GlyphAtlas | ( | Type | type, |
size_t | initial_generation | ||
) |
Create an empty glyph atlas.
[in] | type | How the glyphs are represented in the texture. |
[in] | initial_generation | the atlas generation. |
Definition at line 49 of file glyph_atlas.cc.
|
default |
void impeller::GlyphAtlas::AddTypefaceGlyphPositionAndBounds | ( | const FontGlyphPair & | pair, |
Rect | position, | ||
Rect | bounds | ||
) |
Record the location of a specific font-glyph pair within the atlas.
[in] | pair | The font-glyph pair |
[in] | rect | The position in the atlas |
[in] | bounds | The bounds of the glyph at scale |
Definition at line 78 of file glyph_atlas.cc.
References impeller::FontGlyphPair::glyph, and impeller::FontGlyphPair::scaled_font.
std::optional< FrameBounds > impeller::GlyphAtlas::FindFontGlyphBounds | ( | const FontGlyphPair & | pair | ) | const |
Find the location of a specific font-glyph pair in the atlas.
[in] | pair | The font-glyph pair |
std::nullopt
if the pair is not in the atlas. Definition at line 87 of file glyph_atlas.cc.
References impeller::FontGlyphPair::glyph, and impeller::FontGlyphPair::scaled_font.
Referenced by impeller::BulkUpdateAtlasBitmap(), and impeller::UpdateAtlasBitmap().
size_t impeller::GlyphAtlas::GetAtlasGeneration | ( | ) | const |
Retrieve the generation id for this glyph atlas.
The generation id is used to match with a TextFrame to determine if the frame is guaranteed to already be populated in the atlas.
Definition at line 70 of file glyph_atlas.cc.
size_t impeller::GlyphAtlas::GetGlyphCount | ( | ) | const |
Get the number of unique font-glyph pairs in this atlas.
Definition at line 103 of file glyph_atlas.cc.
References impeller::saturated::b.
FontGlyphAtlas * impeller::GlyphAtlas::GetOrCreateFontGlyphAtlas | ( | const ScaledFont & | scaled_font | ) |
Obtain an interface for querying the location of glyphs in the atlas for the given font and scale. This provides a more efficient way to look up a run of glyphs in the same font.
[in] | font | The font |
[in] | scale | The scale |
Definition at line 96 of file glyph_atlas.cc.
const std::shared_ptr< Texture > & impeller::GlyphAtlas::GetTexture | ( | ) | const |
Get the texture for the glyph atlas.
Definition at line 62 of file glyph_atlas.cc.
Referenced by impeller::BulkUpdateAtlasBitmap(), and impeller::UpdateAtlasBitmap().
GlyphAtlas::Type impeller::GlyphAtlas::GetType | ( | ) | const |
Describes how the glyphs are represented in the texture.
Definition at line 58 of file glyph_atlas.cc.
Referenced by impeller::BulkUpdateAtlasBitmap(), impeller::GetImageInfo(), and impeller::UpdateAtlasBitmap().
bool impeller::GlyphAtlas::IsValid | ( | ) | const |
Definition at line 54 of file glyph_atlas.cc.
size_t impeller::GlyphAtlas::IterateGlyphs | ( | const std::function< bool(const ScaledFont &scaled_font, const SubpixelGlyph &glyph, const Rect &rect)> & | iterator | ) | const |
Iterate of all the glyphs along with their locations in the atlas.
[in] | iterator | The iterator. Return false from the iterator to stop iterating. |
Definition at line 110 of file glyph_atlas.cc.
void impeller::GlyphAtlas::SetAtlasGeneration | ( | size_t | value | ) |
Update the atlas generation.
Definition at line 74 of file glyph_atlas.cc.
void impeller::GlyphAtlas::SetTexture | ( | std::shared_ptr< Texture > | texture | ) |
Set the texture for the glyph atlas.
[in] | texture | The texture |
Definition at line 66 of file glyph_atlas.cc.