RAMSES Documentation  27.0.130
Information for RAMSES users and developers
Public Member Functions | Public Attributes | List of all members
ramses::FontRegistry Class Reference

Font registry can be used to load Freetype2 fonts and create font instances (optionally with Harfbuzz). These are owned and managed by FontRegistry. More...

#include <FontRegistry.h>

Inheritance diagram for ramses::FontRegistry:
[legend]
Collaboration diagram for ramses::FontRegistry:
[legend]

Public Member Functions

 FontRegistry ()
 Constructor for FontRegistry. More...
 
virtual ~FontRegistry () override
 Destructor for FontRegistry. Destroys all created fonts. More...
 
virtual IFontInstancegetFontInstance (FontInstanceId fontInstanceId) const override
 Get font instance object corresponding to given id. More...
 
FontId createFreetype2Font (const char *fontPath)
 Load Freetype2 font from file. More...
 
FontId createFreetype2FontFromFileDescriptor (int fd, size_t offset, size_t length)
 Load Freetype2 font from an open file descriptor. More...
 
FontInstanceId createFreetype2FontInstance (FontId fontId, uint32_t size, bool forceAutohinting=false)
 Create Freetype2 font instance. More...
 
FontInstanceId createFreetype2FontInstanceWithHarfBuzz (FontId fontId, uint32_t size, bool forceAutohinting=false)
 Create Freetype2 font instance with Harfbuzz shaping. More...
 
bool deleteFont (FontId fontId)
 Delete an existing font. More...
 
bool deleteFontInstance (FontInstanceId fontInstance)
 Delete an existing font instance. More...
 
 FontRegistry (const FontRegistry &other)=delete
 Deleted copy constructor. More...
 
FontRegistryoperator= (const FontRegistry &other)=delete
 Deleted copy assignment. More...
 
- Public Member Functions inherited from ramses::IFontAccessor
virtual ~IFontAccessor ()=default
 Empty destructor. More...
 

Public Attributes

class FontRegistryImpl & impl
 

Detailed Description

Font registry can be used to load Freetype2 fonts and create font instances (optionally with Harfbuzz). These are owned and managed by FontRegistry.

Examples
ramses-example-text-basic/src/main.cpp, and ramses-example-text-languages/src/main.cpp.

Constructor & Destructor Documentation

◆ FontRegistry() [1/2]

ramses::FontRegistry::FontRegistry ( )

Constructor for FontRegistry.

◆ ~FontRegistry()

virtual ramses::FontRegistry::~FontRegistry ( )
overridevirtual

Destructor for FontRegistry. Destroys all created fonts.

◆ FontRegistry() [2/2]

ramses::FontRegistry::FontRegistry ( const FontRegistry other)
delete

Deleted copy constructor.

Parameters
otherunused

Member Function Documentation

◆ createFreetype2Font()

FontId ramses::FontRegistry::createFreetype2Font ( const char *  fontPath)

Load Freetype2 font from file.

Parameters
[in]fontPathThe file path to the font
Returns
The font id, FontId::Invalid() on error
Examples
ramses-example-text-basic/src/main.cpp, and ramses-example-text-languages/src/main.cpp.

◆ createFreetype2FontFromFileDescriptor()

FontId ramses::FontRegistry::createFreetype2FontFromFileDescriptor ( int  fd,
size_t  offset,
size_t  length 
)

Load Freetype2 font from an open file descriptor.

The font file must be in the already opened filedescriptor at absolute position offset within the file. The filedescriptor must be opened for read access and may not be modified anymore after this call. The filedescriptor must support seeking. Ramses takes ownership of the filedescriptor and will close it when not needed anymore.

The behavior is undefined if the filedescriptor does not contain a complete and valid font at offset.

Parameters
[in]fdOpen and readable filedescriptor.
[in]offsetAbsolute starting position of the font data within fd.
[in]lengthSize of the font data within fd.
Returns
The font id, FontId::Invalid() on error

◆ createFreetype2FontInstance()

FontInstanceId ramses::FontRegistry::createFreetype2FontInstance ( FontId  fontId,
uint32_t  size,
bool  forceAutohinting = false 
)

Create Freetype2 font instance.

Parameters
[in]fontIdThe id of the font from which to create a font instance
[in]sizeSize (height in rasterized texels of glyphs) of the font
[in]forceAutohintingForce autohinting (a flag for FT2 library)
Returns
The font instance id, FontInstanceId::Invalid() on error
Examples
ramses-example-text-basic/src/main.cpp, and ramses-example-text-languages/src/main.cpp.

◆ createFreetype2FontInstanceWithHarfBuzz()

FontInstanceId ramses::FontRegistry::createFreetype2FontInstanceWithHarfBuzz ( FontId  fontId,
uint32_t  size,
bool  forceAutohinting = false 
)

Create Freetype2 font instance with Harfbuzz shaping.

Parameters
[in]fontIdThe id of the font from which to create a font instance
[in]sizeSize (in rasterized texels of glyphs) of the font
[in]forceAutohintingForce autohinting (a flag for FT2 library)
Returns
The font instance id, FontInstanceId::Invalid() on error
Examples
ramses-example-text-languages/src/main.cpp.

◆ deleteFont()

bool ramses::FontRegistry::deleteFont ( FontId  fontId)

Delete an existing font.

Parameters
[in]fontIdThe id of the font to be deleted
Returns
True on success, false otherwise

◆ deleteFontInstance()

bool ramses::FontRegistry::deleteFontInstance ( FontInstanceId  fontInstance)

Delete an existing font instance.

Parameters
[in]fontInstanceThe id of the font instance to be deleted
Returns
True on success, false otherwise

◆ getFontInstance()

virtual IFontInstance* ramses::FontRegistry::getFontInstance ( FontInstanceId  fontInstanceId) const
overridevirtual

Get font instance object corresponding to given id.

Parameters
[in]fontInstanceIdThe id of font instance
Returns
The font instance object, nullptr if not found

Implements ramses::IFontAccessor.

◆ operator=()

FontRegistry& ramses::FontRegistry::operator= ( const FontRegistry other)
delete

Deleted copy assignment.

Parameters
otherunused
Returns
unused

Member Data Documentation

◆ impl

class FontRegistryImpl& ramses::FontRegistry::impl

Stores internal data for implementation specifics of FontRegistry.


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