lxgui
Public Member Functions | List of all members
lxgui::gui::font Class Referenceabstract

A texture containing characters. More...

#include <gui_font.hpp>

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

Public Member Functions

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

Detailed Description

A texture containing characters.

This class is purely virtual. It needs to be implemented and created by the corresponding gui::renderer.

Definition at line 22 of file gui_font.hpp.

Constructor & Destructor Documentation

◆ font()

lxgui::gui::font::font ( )
default

Constructor.

◆ ~font()

virtual lxgui::gui::font::~font ( )
virtualdefault

Destructor.

Reimplemented in lxgui::gui::gl::font.

Member Function Documentation

◆ get_character_bounds()

virtual bounds2f lxgui::gui::font::get_character_bounds ( char32_t  c) const
pure virtual

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)

Implemented in lxgui::gui::sfml::font, lxgui::gui::sdl::font, and lxgui::gui::gl::font.

◆ get_character_height()

virtual float lxgui::gui::font::get_character_height ( char32_t  c) const
pure virtual

Returns the height of a character in pixels.

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

Implemented in lxgui::gui::sfml::font, lxgui::gui::sdl::font, and lxgui::gui::gl::font.

◆ get_character_kerning()

virtual float lxgui::gui::font::get_character_kerning ( char32_t  c1,
char32_t  c2 
) const
pure virtual

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).

Implemented in lxgui::gui::sfml::font, lxgui::gui::sdl::font, and lxgui::gui::gl::font.

◆ get_character_uvs()

virtual bounds2f lxgui::gui::font::get_character_uvs ( char32_t  c) const
pure virtual

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}.

Implemented in lxgui::gui::sfml::font, lxgui::gui::sdl::font, and lxgui::gui::gl::font.

◆ get_character_width()

virtual float lxgui::gui::font::get_character_width ( char32_t  c) const
pure virtual

Returns the width of a character in pixels.

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

Implemented in lxgui::gui::sfml::font, lxgui::gui::sdl::font, and lxgui::gui::gl::font.

◆ get_size()

virtual std::size_t lxgui::gui::font::get_size ( ) const
pure virtual

Get the size of the font in pixels.

Returns
The size of the font in pixels

Implemented in lxgui::gui::sfml::font, lxgui::gui::sdl::font, and lxgui::gui::gl::font.

◆ get_texture()

virtual std::weak_ptr<material> lxgui::gui::font::get_texture ( ) const
pure virtual

Returns the underlying material to use for rendering.

Returns
The underlying material to use for rendering

Implemented in lxgui::gui::sfml::font, lxgui::gui::sdl::font, and lxgui::gui::gl::font.

◆ update_texture()

virtual void lxgui::gui::font::update_texture ( std::shared_ptr< material mat)
pure virtual

Update the material to use for rendering.

Parameters
matThe material to use for rendering

Implemented in lxgui::gui::sfml::font, lxgui::gui::sdl::font, and lxgui::gui::gl::font.


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