lxgui
Classes | Public Member Functions | List of all members
lxgui::gui::gl::font Class Referencefinal

A texture containing characters This is the OpenGL implementation of the gui::font. It uses the freetype library to read data from .ttf and .otf files and to render the characters on the font texture. More...

#include <gui_gl_font.hpp>

Inheritance diagram for lxgui::gui::gl::font:
lxgui::gui::font

Public Member Functions

 font (const std::string &font_file, std::size_t size, std::size_t outline, const std::vector< code_point_range > &code_points, char32_t default_code_point)
 Constructor. More...
 
 ~font () override
 Destructor. More...
 
std::size_t get_size () const override
 Get the size of the font in pixels. More...
 
bounds2f get_character_uvs (char32_t c) const override
 Returns the uv coordinates of a character on the texture. More...
 
bounds2f get_character_bounds (char32_t c) const override
 Returns the rect coordinates of a character as it should be drawn relative to the baseline. More...
 
float get_character_width (char32_t c) const override
 Returns the width of a character in pixels. More...
 
float get_character_height (char32_t c) const override
 Returns the height of a character in pixels. More...
 
float get_character_kerning (char32_t c1, char32_t c2) const override
 Return the kerning amount between two characters. More...
 
std::weak_ptr< gui::materialget_texture () const override
 Returns the underlying material to use for rendering. More...
 
void update_texture (std::shared_ptr< gui::material > mat) override
 Update the material to use for rendering. More...
 

Detailed Description

A texture containing characters This is the OpenGL implementation of the gui::font. It uses the freetype library to read data from .ttf and .otf files and to render the characters on the font texture.

Definition at line 20 of file gui_gl_font.hpp.

Constructor & Destructor Documentation

◆ font()

lxgui::gui::gl::font::font ( const std::string &  font_file,
std::size_t  size,
std::size_t  outline,
const std::vector< code_point_range > &  code_points,
char32_t  default_code_point 
)

Constructor.

Parameters
font_fileThe name of the font file to read
sizeThe requested size of the characters (in points)
outlineThe thickness of the outline (in points)
code_pointsThe list of Unicode characters to load
default_code_pointThe character to display as fallback

◆ ~font()

lxgui::gui::gl::font::~font ( )
overridevirtual

Destructor.

Reimplemented from lxgui::gui::font.

Member Function Documentation

◆ get_character_bounds()

bounds2f lxgui::gui::gl::font::get_character_bounds ( char32_t  c) const
overridevirtual

Returns the rect coordinates of a character as it should be drawn relative to the baseline.

Parameters
cThe unicode character
Returns
The rect coordinates of this character (in pixels, relative to the baseline)

Implements lxgui::gui::font.

◆ get_character_height()

float lxgui::gui::gl::font::get_character_height ( char32_t  c) const
overridevirtual

Returns the height of a character in pixels.

Parameters
cThe unicode character
Returns
The height of the character in pixels.

Implements lxgui::gui::font.

◆ get_character_kerning()

float lxgui::gui::gl::font::get_character_kerning ( char32_t  c1,
char32_t  c2 
) const
overridevirtual

Return the kerning amount between two characters.

Parameters
c1The first unicode character
c2The second unicode character
Returns
The kerning amount between the two characters
Note
Kerning is a font rendering adjustment that makes some letters closer, for example in 'VA', there is room for the two to be closer than with 'VW'. This has no effect for fixed width fonts (like Courrier, etc).

Implements lxgui::gui::font.

◆ get_character_uvs()

bounds2f lxgui::gui::gl::font::get_character_uvs ( char32_t  c) const
overridevirtual

Returns the uv coordinates of a character on the texture.

Parameters
cThe unicode character
Returns
The uv coordinates of this character on the texture
Note
The uv coordinates are normalized, i.e. they range from 0 to 1. They are arranged as {u1, v1, u2, v2}.

Implements lxgui::gui::font.

◆ get_character_width()

float lxgui::gui::gl::font::get_character_width ( char32_t  c) const
overridevirtual

Returns the width of a character in pixels.

Parameters
cThe unicode character
Returns
The width of the character in pixels.

Implements lxgui::gui::font.

◆ get_size()

std::size_t lxgui::gui::gl::font::get_size ( ) const
overridevirtual

Get the size of the font in pixels.

Returns
The size of the font in pixels

Implements lxgui::gui::font.

◆ get_texture()

std::weak_ptr<gui::material> lxgui::gui::gl::font::get_texture ( ) const
overridevirtual

Returns the underlying material to use for rendering.

Returns
The underlying material to use for rendering

Implements lxgui::gui::font.

◆ update_texture()

void lxgui::gui::gl::font::update_texture ( std::shared_ptr< gui::material mat)
overridevirtual

Update the material to use for rendering.

Parameters
matThe material to use for rendering

Implements lxgui::gui::font.


The documentation for this class was generated from the following file: