Antkeeper
0.0.1
|
Raster font in which glyphs are stored as arrays of pixels. More...
#include <bitmap-font.hpp>
Public Member Functions | |
bitmap_font (const font_metrics &metrics) | |
Creates a bitmap font and sets its metrics. More... | |
bitmap_font () | |
Creates an empty bitmap font. More... | |
virtual | ~bitmap_font ()=default |
Destroys a bitmap font. More... | |
virtual bool | contains (char32_t code) const |
Returns true if the font contains a glyph with the given character code. More... | |
bitmap_glyph & | insert (char32_t code) |
Inserts a glyph into the font. More... | |
void | remove (char32_t code) |
Removes a glyph from the font. More... | |
void | clear () |
Removes all glyphs from the font. More... | |
bool | pack (bool resize=true) |
Packs all glyph bitmaps into the font bitmap. More... | |
void | unpack (bool resize=true) |
Unpacks all glyph bitmaps from the font bitmap. More... | |
virtual const glyph_metrics & | get_glyph_metrics (char32_t code) const |
Returns metrics describing a glyph. More... | |
const std::shared_ptr< gl::texture_2d > & | get_texture () const noexcept |
Returns a pointer to the glyph corresponding to a UTF-32 character code, or nullptr if no such glyph was found. More... | |
const bitmap_glyph * | get_glyph (char32_t code) const |
Returns a pointer to the glyph corresponding to a UTF-32 character code, or nullptr if no such glyph was found. More... | |
bitmap_glyph * | get_glyph (char32_t code) |
Returns a pointer to the glyph corresponding to a UTF-32 character code, or nullptr if no such glyph was found. More... | |
![]() | |
font (const font_metrics &metrics) | |
Creates a font and sets its metrics. More... | |
font () | |
Creates an empty font. More... | |
virtual | ~font () |
Destroys a font. More... | |
void | kern (char32_t first, char32_t second, const math::fvec2 &offset) |
Sets the kerning offset for a pair of glyphs. More... | |
void | set_font_metrics (const font_metrics &metrics) |
Sets the font metrics. More... | |
const math::fvec2 & | get_kerning (char32_t first, char32_t second) const |
Returns the kerning offset for a pair of glyphs. More... | |
const kerning_table & | get_kerning_table () const |
Returns the font's kerning table. More... | |
const font_metrics & | get_font_metrics () const |
Returns metrics describing the font. More... | |
Additional Inherited Members | |
![]() | |
font_metrics | metrics |
kerning_table | kerning_table |
Raster font in which glyphs are stored as arrays of pixels.
Definition at line 38 of file bitmap-font.hpp.
|
explicit |
Creates a bitmap font and sets its metrics.
metrics | Metrics describing the font. |
Definition at line 26 of file bitmap-font.cpp.
type::bitmap_font::bitmap_font | ( | ) |
Creates an empty bitmap font.
Definition at line 30 of file bitmap-font.cpp.
|
virtualdefault |
Destroys a bitmap font.
void type::bitmap_font::clear | ( | ) |
Removes all glyphs from the font.
Definition at line 52 of file bitmap-font.cpp.
|
virtual |
Returns true
if the font contains a glyph with the given character code.
code | UTF-32 character code of a glyph. |
true
if the font contains the glyph, false
otherwise. Implements type::font.
Definition at line 34 of file bitmap-font.cpp.
bitmap_glyph * type::bitmap_font::get_glyph | ( | char32_t | code | ) |
Returns a pointer to the glyph corresponding to a UTF-32 character code, or nullptr
if no such glyph was found.
code | UTF-32 character code of a glyph. |
Definition at line 236 of file bitmap-font.cpp.
const bitmap_glyph * type::bitmap_font::get_glyph | ( | char32_t | code | ) | const |
Returns a pointer to the glyph corresponding to a UTF-32 character code, or nullptr
if no such glyph was found.
code | UTF-32 character code of a glyph. |
Definition at line 226 of file bitmap-font.cpp.
|
virtual |
Returns metrics describing a glyph.
code | UTF-32 character code of a glyph. |
@except std::invalid_argument Cannot fetch metrics of unknown bitmap glyph
Implements type::font.
Definition at line 217 of file bitmap-font.cpp.
|
inlinenoexcept |
Returns a pointer to the glyph corresponding to a UTF-32 character code, or nullptr
if no such glyph was found.
code | UTF-32 character code of a glyph. |
Definition at line 118 of file bitmap-font.hpp.
bitmap_glyph & type::bitmap_font::insert | ( | char32_t | code | ) |
Inserts a glyph into the font.
code | UTF-32 character code of the glyph to insert. |
Definition at line 39 of file bitmap-font.cpp.
bool type::bitmap_font::pack | ( | bool | resize = true | ) |
Packs all glyph bitmaps into the font bitmap.
resize | Automatically resize the font bitmap to contain all glyphs. Bitmap size will start at the closest power of two to the largest glyph, then its dimensions will increase to the next power of two until its large enough that all glyphs can be contained. |
true
if all glyphs were successfully packed, false
otherwise.@except std::runtime_error Glyph bitmap format doesn't match font bitmap format. @except std::runtime_error Not enough space in font bitmap to pack glyph.
Definition at line 57 of file bitmap-font.cpp.
void type::bitmap_font::remove | ( | char32_t | code | ) |
Removes a glyph from the font.
code | UTF-32 character code of the glyph to remove. |
Definition at line 44 of file bitmap-font.cpp.
void type::bitmap_font::unpack | ( | bool | resize = true | ) |
Unpacks all glyph bitmaps from the font bitmap.
resize | Automatically resizes the font bitmap to zero. |