#include <StkFont.h>
|
| Font (const std::string &font_id, const std::string &font_name) |
|
const std::string & | getFontID () const |
|
const std::string & | getFontName () const |
|
int | getFontNumber () const |
| Return unique integer ID for this font.
|
|
bool | initFontData (const std::string &filename, int font_size, int font_idx=0) |
| Initialize font.
|
|
void | updateTexture () |
| Update the OpenGL texture. This is normally done on demand, but may also be called explicitly if you need to keep control of when this should happen.
|
|
void | clearTexture () |
| Clear OpenGL texture data. Requires a valid OpenGL context.
|
|
Font::GlyphInfo | makeGlyphInfo (uint32_t character, float &offsetX, float &offsetY) |
|
void | bindTexture () |
|
int | getTextureHandle () const |
|
void | saveTextureAtlas (const std::string &filename="") |
|
float | getAscent () const |
| Get max distance (in pixels) above the baseline for this font.
|
|
float | getDescent () const |
| Get max distance (in pixels) below the baseline for this font.
|
|
float | getLineGap () const |
| Get spacing (in pixels) between one row's descent and the next row's ascent for this font.
|
|
float | getLineDistance () const |
| Get default distance (in pixels) between two rows in this font.
|
|
int | getPixelSize () const |
| Get font size (in pixels).
|
|
int | getTetureAtlasPixelSize () const |
|
void | getAdvanceBearing (int codepoint, float &advance, float &bearing) |
| Get horizontal metrics (in pixels) for the given character. Bearing is the offset from the current horizontal position to the left edge of the character. advance is the offset from the current horizontal position to the next horizontal position.
|
|
|
static double | pointToPixelSize (double pt_size, double dpi=96) |
|
static double | pixelToPointSize (double px_size, double dpi=96) |
|
static int | calcTextureAtlasPixelSize (int px_size) |
|
|
template<class T > |
void | findCharRanges (std::vector< std::unique_ptr< T > > &char_ranges, int max_cp) |
|
template<class T > |
int | calcMaxPackedCodepoint (const std::vector< std::unique_ptr< T > > &char_ranges) const |
|
virtual bool | getCharacterQuad (int codepoint, stbtt_aligned_quad &quad, float &offsetX, float &offsetY)=0 |
|
|
std::string | font_id_ |
|
std::string | font_name_ |
|
std::string | font_filename_ |
|
int | font_num_ = 0 |
|
int | font_size_ = 0 |
|
int | bake_size_ = 0 |
|
float | font_scale_ = 0.0f |
|
int | atlas_width_ = 0 |
|
int | atlas_height_ = 0 |
|
std::unique_ptr< uint8_t[]> | atlas_data_ |
|
GLuint | texture_ = 0 |
|
bool | texture_dirty_ = false |
|
std::unique_ptr< stbtt_fontinfo > | font_info_ |
|
std::vector< uint8_t > | font_data_ |
|
int | font_idx_ = 0 |
|
|
static int | s_font_num_ = 1 |
|
Font - Base class for STK fonts.
◆ bindTexture()
void STK::Font::bindTexture |
( |
| ) |
|
|
inline |
Update and bind OpenGL texture object. This method will update the OpenGL texture data if there has been any changes to the underlying atlas, and then bind the texture handle.
◆ getAdvanceBearing()
void STK::Font::getAdvanceBearing |
( |
int |
codepoint, |
|
|
float & |
advance, |
|
|
float & |
bearing |
|
) |
| |
|
inline |
Get horizontal metrics (in pixels) for the given character. Bearing is the offset from the current horizontal position to the left edge of the character. advance is the offset from the current horizontal position to the next horizontal position.
- Parameters
-
codepoint | The unicode codepoint for a character. |
advance | Output advance (in pixels) for the character. |
bearing | Output bearing (in pixels) for the character. |
◆ getFontID()
const std::string & STK::Font::getFontID |
( |
| ) |
const |
|
inline |
Internal font ID. This is used by the font manager. Note that this is usually not the same as the font name.
◆ getFontName()
const std::string & STK::Font::getFontName |
( |
| ) |
const |
|
inline |
Name string for the font. This is usually the font family name. This name can be used to look up the full font entry in the FontManager.
- See also
- FontManager::getFontEntry
◆ getFontNumber()
int STK::Font::getFontNumber |
( |
| ) |
const |
|
inline |
Return unique integer ID for this font.
- Returns
◆ getPixelSize()
int STK::Font::getPixelSize |
( |
| ) |
const |
|
inline |
Get font size (in pixels).
- Returns
◆ getTetureAtlasPixelSize()
int STK::Font::getTetureAtlasPixelSize |
( |
| ) |
const |
|
inline |
Get the pixel size used for baking the glyphs in the texture. For huge fonts this will typically be smaller than getPixelSize and the font is scaled to the wanted size.
◆ initFontData()
bool Font::initFontData |
( |
const std::string & |
filename, |
|
|
int |
font_size, |
|
|
int |
font_idx = 0 |
|
) |
| |
Initialize font.
- Parameters
-
filename | |
font_size | Font size (in pixels) |
font_idx | |
- Returns
◆ makeGlyphInfo()
Font::GlyphInfo Font::makeGlyphInfo |
( |
uint32_t |
character, |
|
|
float & |
offsetX, |
|
|
float & |
offsetY |
|
) |
| |
Calculate glyph vertex and texture coordinates for the given Unicode character code. The vertices will be offset by the input offset values. The offset values will be increased by the glyphs advance and can be used to place the next character on the line.
◆ saveTextureAtlas()
void Font::saveTextureAtlas |
( |
const std::string & |
filename = "" | ) |
|
Save texture atlas to file as PNG. This method is mostly useful for debugging. If no filename is given, a name is generated from the font name.
The documentation for this class was generated from the following files:
- Native/SilentToolkit/StkScene/StkFont.h
- Native/SilentToolkit/StkScene/StkFont.cpp