Castor3D 0.17.0
Multiplatform 3D engine
Classes | Public Types | Public Member Functions | Friends | List of all members
castor::Font Class Reference

#include <Font.hpp>

Inheritance diagram for castor::Font:
Inheritance graph
[legend]
Collaboration diagram for castor::Font:
Collaboration graph
[legend]

Classes

class  BinaryLoader
 Font loader. More...
 
struct  GlyphLoader
 Structure used to load glyphs on demand. More...
 
struct  SdfInfo
 

Public Types

using GlyphKerning = Map< char32_t, float >
 
using GlyphKerningMap = Map< char32_t, GlyphKerning >
 

Public Member Functions

 CU_DeclareVector (Glyph, Glyph)
 
CU_API Font (String const &name, uint32_t height)
 Non SDF font constructor.
 
CU_API Font (String const &name, uint32_t height, Path const &path)
 Non SDF font constructor.
 
CU_API Font (String const &name)
 SDF font constructor.
 
CU_API Font (String const &name, Path const &path)
 SDF font constructor.
 
virtual CU_API ~Font () noexcept=default
 Destructor.
 
CU_API void loadGlyph (char32_t c)
 Loads wanted glyph.
 
CU_API TextMetrics getTextMetrics (std::u32string const &v, uint32_t maxWidth, bool splitLines, uint32_t height) const
 Retrieves the metrics of given text.
 
CU_API TextMetrics getTextMetrics (std::u32string const &v, uint32_t maxWidth, bool splitLines) const
 Retrieves the metrics of given text.
 
CU_API float getKerning (char32_t lhs, char32_t rhs, uint32_t height) const
 Retrieves the kerning between two characters.
 
CU_API float getKerning (char32_t lhs, char32_t rhs) const
 Retrieves the kerning between two characters.
 
bool hasGlyphAt (char32_t c) const
 
Glyph const & getGlyphAt (char32_t c) const
 
GlyphgetGlyphAt (char32_t c)
 
Array access.
Glyph const & operator[] (char32_t c) const
 
Glyphoperator[] (char32_t c)
 
Iteration.
auto begin () noexcept
 
auto begin () const noexcept
 
auto end () noexcept
 
auto end () const noexcept
 
Getters.
uint32_t getHeight () const noexcept
 
uint32_t getMaxGlyphHeight () const noexcept
 
uint32_t getMaxGlyphWidth () const noexcept
 
Point2f getMaxBearing () const noexcept
 
uint32_t getMaxImageWidth () const noexcept
 
uint32_t getMaxImageHeight () const noexcept
 
bool hasGlyphLoader () const noexcept
 
GlyphLoadergetGlyphLoader () const noexcept
 
String const & getFaceName () const noexcept
 
Path const & getFilePath () const noexcept
 
bool isSerialisable () const noexcept
 
bool isSDF () const noexcept
 
float getPixelRange () const noexcept
 
float getVerticalAdvance () const noexcept
 
- Public Member Functions inherited from castor::NamedBaseT< T >
 NamedBaseT (T name) noexcept
 Constructor.
 
T const & getName () const noexcept
 Retrieves the name.
 
void rename (T name) noexcept
 

Friends

class BinaryLoader
 

Mutators.

void setGlyphLoader (castor::RawUniquePtr< GlyphLoader > loader) noexcept
 
void setFaceName (String name) noexcept
 
void setSerialisable (bool v) noexcept
 

Additional Inherited Members

- Protected Attributes inherited from castor::NamedBaseT< T >
m_name
 

Member Typedef Documentation

◆ GlyphKerning

using castor::Font::GlyphKerning = Map< char32_t, float >

◆ GlyphKerningMap

Constructor & Destructor Documentation

◆ Font() [1/4]

CU_API castor::Font::Font ( String const & name,
uint32_t height )

Non SDF font constructor.

Parameters
[in]nameThe font name.
[in]heightThe font char height.

◆ Font() [2/4]

CU_API castor::Font::Font ( String const & name,
uint32_t height,
Path const & path )

Non SDF font constructor.

Parameters
[in]pathThe font file path.
[in]nameThe font name.
[in]heightThe font char height.

◆ Font() [3/4]

CU_API castor::Font::Font ( String const & name)
explicit

SDF font constructor.

Parameters
[in]nameThe font name.

◆ Font() [4/4]

CU_API castor::Font::Font ( String const & name,
Path const & path )

SDF font constructor.

Parameters
[in]pathThe font file path.
[in]nameThe font name.

◆ ~Font()

virtual CU_API castor::Font::~Font ( )
virtualdefaultnoexcept

Destructor.

Remarks
Virtual to enable use as ResourceT.

Member Function Documentation

◆ begin() [1/2]

auto castor::Font::begin ( ) const
inlinenoexcept

◆ begin() [2/2]

auto castor::Font::begin ( )
inlinenoexcept

◆ CU_DeclareVector()

castor::Font::CU_DeclareVector ( Glyph ,
Glyph  )

◆ end() [1/2]

auto castor::Font::end ( ) const
inlinenoexcept

◆ end() [2/2]

auto castor::Font::end ( )
inlinenoexcept

◆ getFaceName()

String const & castor::Font::getFaceName ( ) const
inlinenoexcept

◆ getFilePath()

Path const & castor::Font::getFilePath ( ) const
inlinenoexcept

◆ getGlyphAt() [1/2]

Glyph & castor::Font::getGlyphAt ( char32_t c)
inline
Parameters
[in]cThe wanted character.
Returns
The glyph of wanted character.

◆ getGlyphAt() [2/2]

Glyph const & castor::Font::getGlyphAt ( char32_t c) const
inline
Parameters
[in]cThe wanted character.
Returns
The glyph of wanted character.

◆ getGlyphLoader()

GlyphLoader & castor::Font::getGlyphLoader ( ) const
inlinenoexcept

References CU_Require, and hasGlyphLoader().

Here is the call graph for this function:

◆ getHeight()

uint32_t castor::Font::getHeight ( ) const
inlinenoexcept

References CU_Require, and isSDF().

Here is the call graph for this function:

◆ getKerning() [1/2]

CU_API float castor::Font::getKerning ( char32_t lhs,
char32_t rhs ) const

Retrieves the kerning between two characters.

Remarks
Uses the font height defined at construction.
Parameters
[in]lhs,rhsThe characters.

◆ getKerning() [2/2]

CU_API float castor::Font::getKerning ( char32_t lhs,
char32_t rhs,
uint32_t height ) const

Retrieves the kerning between two characters.

Parameters
[in]lhs,rhsThe characters.
[in]heightThe font height considered for computing.

◆ getMaxBearing()

Point2f castor::Font::getMaxBearing ( ) const
inlinenoexcept

◆ getMaxGlyphHeight()

uint32_t castor::Font::getMaxGlyphHeight ( ) const
inlinenoexcept

◆ getMaxGlyphWidth()

uint32_t castor::Font::getMaxGlyphWidth ( ) const
inlinenoexcept

◆ getMaxImageHeight()

uint32_t castor::Font::getMaxImageHeight ( ) const
inlinenoexcept

◆ getMaxImageWidth()

uint32_t castor::Font::getMaxImageWidth ( ) const
inlinenoexcept

◆ getPixelRange()

float castor::Font::getPixelRange ( ) const
inlinenoexcept

◆ getTextMetrics() [1/2]

CU_API TextMetrics castor::Font::getTextMetrics ( std::u32string const & v,
uint32_t maxWidth,
bool splitLines ) const

Retrieves the metrics of given text.

Remarks
Uses the font height defined at construction.
Parameters
[in]vThe text.
[in]maxWidthThe maximum width if splitLines is true.
[in]splitLinestrue to split lines according to maxWidth.

◆ getTextMetrics() [2/2]

CU_API TextMetrics castor::Font::getTextMetrics ( std::u32string const & v,
uint32_t maxWidth,
bool splitLines,
uint32_t height ) const

Retrieves the metrics of given text.

Parameters
[in]vThe text.
[in]maxWidthThe maximum width if splitLines is true.
[in]splitLinestrue to split lines according to maxWidth.
[in]heightThe font height considered for computing.

◆ getVerticalAdvance()

float castor::Font::getVerticalAdvance ( ) const
inlinenoexcept

References isSDF().

Here is the call graph for this function:

◆ hasGlyphAt()

bool castor::Font::hasGlyphAt ( char32_t c) const
inline
Parameters
[in]cThe character.
Returns
true if the font already has loaded the wanted glyph.

Referenced by operator[](), and operator[]().

Here is the caller graph for this function:

◆ hasGlyphLoader()

bool castor::Font::hasGlyphLoader ( ) const
inlinenoexcept

Referenced by getGlyphLoader().

Here is the caller graph for this function:

◆ isSDF()

bool castor::Font::isSDF ( ) const
inlinenoexcept

Referenced by getHeight(), and getVerticalAdvance().

Here is the caller graph for this function:

◆ isSerialisable()

bool castor::Font::isSerialisable ( ) const
inlinenoexcept

◆ loadGlyph()

CU_API void castor::Font::loadGlyph ( char32_t c)

Loads wanted glyph.

Parameters
[in]cThe character.

◆ operator[]() [1/2]

Glyph & castor::Font::operator[] ( char32_t c)
inline

References CU_Ensure, and hasGlyphAt().

Here is the call graph for this function:

◆ operator[]() [2/2]

Glyph const & castor::Font::operator[] ( char32_t c) const
inline

References CU_Ensure, and hasGlyphAt().

Here is the call graph for this function:

◆ setFaceName()

void castor::Font::setFaceName ( String name)
inlinenoexcept

◆ setGlyphLoader()

void castor::Font::setGlyphLoader ( castor::RawUniquePtr< GlyphLoader > loader)
inlinenoexcept

◆ setSerialisable()

void castor::Font::setSerialisable ( bool v)
inlinenoexcept

Friends And Related Symbol Documentation

◆ BinaryLoader

friend class BinaryLoader
friend

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