|
| TextRenderer (const std::filesystem::path &fontPath=font::getFont(font::FontType::Default, font::FullPath::Yes)) |
|
| TextRenderer (const TextRenderer &rhs)=delete |
|
| TextRenderer (TextRenderer &&rhs) noexcept |
|
TextRenderer & | operator= (const TextRenderer &rhs)=delete |
|
TextRenderer & | operator= (TextRenderer &&rhs) noexcept |
|
void | setFont (const std::filesystem::path &fontPath) |
| replace the currently loaded font face with a new one
|
|
std::tuple< utilgl::DepthMaskState, utilgl::GlBoolState, utilgl::BlendModeState, utilgl::ActivateFBO > | setupRenderState (std::shared_ptr< Texture2D > texture, std::optional< vec4 > clearColor=std::nullopt) |
|
void | render (std::string_view str, const vec2 &posf, const vec2 &scale, const vec4 &color) |
|
void | render (std::string_view str, float x, float y, const vec2 &scale, const vec4 &color) |
| renders the given string with the specified color at position x, y in normalized device coordinates [-1,1] using the scaling factor.
|
|
void | render (const TextBoundingBox &textBoundingBox, const ivec2 &origin, std::string_view str, const vec4 &color) |
| renders the given string with the specified color into a subregion of the current destination
|
|
void | renderToTexture (std::shared_ptr< Texture2D > texture, std::string_view str, const vec4 &color, bool clearTexture=true) |
| renders the given string with the specified color into a texture.
|
|
void | renderToTexture (const TextTextureObject &texObject, std::string_view str, const vec4 &color, bool clearTexture=true) |
|
void | renderToTexture (const TextTextureObject &texObject, const size2_t &origin, const size2_t &size, std::string_view str, const vec4 &color, bool clearTexture=true) |
| renders the given string with the specified color into a subregion of the texture.
|
|
void | renderToTexture (std::shared_ptr< Texture2D > texture, const size2_t &origin, const size2_t &size, std::string_view str, const vec4 &color, bool clearTexture=true) |
|
void | renderToTexture (std::shared_ptr< Texture2D > texture, const std::vector< size2_t > &origin, const std::vector< size2_t > &size, const std::vector< std::string > &str, const vec4 &color, bool clearTexture=true) |
|
void | renderToTexture (std::shared_ptr< Texture2D > texture, const std::vector< TexAtlasEntry > &entries, bool clearTexture=true) |
|
void | clear (std::shared_ptr< Texture2D > texture, vec4 color) |
|
vec2 | computeTextSize (std::string_view str, const vec2 &scale) |
| computes the glyph bounding box of a given string in normalized device coordinates using the scaling factor. The vertical height of the bounding box will be about (ascend + descend) + (number of lines - 1) times line height.
|
|
size2_t | computeTextSize (std::string_view str) |
| computes the glyph bounding box of a given string in pixels (screen space). The vertical height of the bounding box will be about (ascend + descend) + (number of lines - 1) times line height.
|
|
TextBoundingBox | computeBoundingBox (std::string_view str) |
| computes the bounding boxes of both text and all glyphs for a given string in pixels (screen space).
|
|
void | setFontSize (int val) |
|
int | getFontSize () const |
|
void | setLineSpacing (double lineSpacing) |
| sets the line spacing relative to the font size (default 0.2 = 20%)
|
|
double | getLineSpacing () const |
|
void | setLineHeight (int lineHeight) |
|
int | getLineHeight () const |
|
int | getBaseLineOffset () const |
| returns the offset of the baseline, which corresponds to ascent
|
|
int | getBaseLineDescender () const |
| returns the size of the font part below the baseline, which corresponds to descent
|
|
void | configure (const FontSettings &settings) |
|
|
double | getFontAscender () const |
|
double | getFontDescender () const |
|
std::pair< bool, GlyphEntry > | requestGlyph (FontCache &fc, unsigned int glyph) |
| request glyph information from the texture atlas. The glyph will be added to the atlas if it isn't registered yet and there is space left in the atlas.
|
|
std::pair< bool, GlyphEntry > | addGlyph (FontCache &fc, unsigned int glyph) |
|
void | uploadGlyph (FontCache &fc, unsigned int glyph) |
|
FontCache & | getFontCache () |
|
void | createDefaultGlyphAtlas () |
|
std::shared_ptr< Texture2D > | createAtlasTexture (FontCache &fc) |
|
FontFamilyStyle | getFontTuple () const |
|
std::string_view::const_iterator | validateString (std::string_view str) const |
|
Render text using the FreeType font library.
The origin is at the top-left corner. The first line starts at origin - ascender (getBaseLineOffset()). The distance between two lines is governed by either setting the line height or the line spacing. The line height defines the distance between two consecutive baselines. In contrast, the line spacing (or line gap) is given by line height minus ascend minus descend. Typically, a line spacing of 20% of the font size is used, which corresponds to a line height of 1.2 * font size.
* Origin
* +───────────────────────────ffffffffffffffff──────────────────── Top line
* f::::::::::::::::f ▲ ▲
* f::::::::::::::::::f │ │
* f::::::fffffff:::::f │ │
* ggggggggg ggggg f:::::f ffffff │ │
* g:::::::::ggg::::g f:::::f │ │
* g:::::::::::::::::g f:::::::ffffff │ │
* g::::::ggggg::::::gg f::::::::::::f │ Ascender
* g:::::g g:::::g f::::::::::::f │ │
* g:::::g g:::::g f:::::::ffffff │ │
* g:::::g g:::::g f:::::f │ │
* g::::::g g:::::g f:::::f │ │
* g:::::::ggggg:::::g f:::::::f │ │
* g::::::::::::::::g f:::::::f Line height │
* gg::::::::::::::g f:::::::f │ ▼
* ────────gggggggg::::::g──fffffffff───────────────│────────────── Base line
* g:::::g │ ▲
* gggggg g:::::g │ │
* g:::::gg gg:::::g │ Descender
* g::::::ggg:::::::g │ │
* gg:::::::::::::g │ │
* ggg::::::ggg │ ▼
* ───────────gggggg────────────────────────────────│────────────── Bottom line
* │ ▲
* │ │
* │ Line spacing
* │ │
* ▼ ▼
* ──────────────────────────────────────────────────────────────── Top line (of subsequent line)
*