| CRM64Pro GDK v0.17.0 A free cross-platform game development kit built on top of SDL 3.0

Loading...
Searching...
No Matches
CRM64Pro::FontMgr
Graphics modules » Font

Font Manager class. More...

## Detailed Description

Font Manager class.

## Public Member Functions
Font * | get (const string &sName)
| Get a pointer to the font using its name.
bool | info (Sint32 iMode=0) override
| Request Font Manager information.
Sint32 | create (const string &sName, Uint32 iVersion=10) override
| Create a new font.
bool | close (Sint32 idFont) override
| Close and destroy a font.
Sint32 | getCount () const override
| Get number of loaded objects.
Sint32 | setName (Sint32 idFont, const string &sName) override
| Change the object name.
Font * | get (Sint32 idFont)
| Get a pointer to the font using its handler.
Sint32 | getBuiltin (const string &sName)
| Get a built-in embedded font id using its name.
Sint32 | child (Sint32 idFont)
| Create a child font dependant on the provided one (the parent).
Sint32 | load (const string &sCDCFile, const string &sName)
| Load a font stored in a CDC file.
Sint32 | load (const Sint32 idCDC, const string &sName)
| Load a font stored in a CDC file.
Sint32 | loadFromBuffer (const void *pBuffer, Sint32 iSize, const string &sName)
| Load a font from an image memory buffer.
Sint32 | remove (const Sint32 idCDC, const string &sName)
| Remove a font stored in a CDC file.
bool | exist (const Sint32 idCDC, const string &sName)
| Check if a font is stored in a CDC file.
bool | exist (const string &sCDCFile, const string &sName)
| Check if a font is stored in a CDC file.

## Member Function Documentation

## ◆ get() [1/2]

Font * CRM64Pro::FontMgr::get | ( | const string & | sName | ) |

Get a pointer to the font using its name.

Parameters

  sName | Font name.

Returns
  nullptr The font was not found.
  A pointer to the font object.

## ◆ info()

bool CRM64Pro::FontMgr::info | ( | Sint32 | iMode = 0 | ) |
| override

Request Font Manager information.

Writes information to the default log.

Parameters

  iMode | -1 for displaying only Manager information. 0 for displaying Manager and all Objects information. This is the default value. Greater than 0 (Font id) for displaying Manager and given Font information.

Returns
  true on success, or false on failure.

## ◆ create()

Sint32 CRM64Pro::FontMgr::create | ( | const string & | sName,
|  | Uint32 | iVersion = 10 )
| override

Create a new font.

This method will create an empty font (no image assigned), use Font::assignImage() method for assigning the image.

Parameters

  sName | The name to give to the font e.g. 'myFont'. The object name must be unique and with a maximum size of 64 characters or will be truncated.
  iVersion | Font version. 10 means 1.0 which is the only version supported (as of now). v1.0 is set by default.

Returns
  Greater than 0 on success (the Font id) or a negative error code on failure.

Note
  If the provided name already exists, it does nothing and return an error code.

## ◆ close()

bool CRM64Pro::FontMgr::close | ( | Sint32 | idFont | ) |
| override

Close and destroy a font.

Parameters

  idFont | 0 for closing all fonts or the Font id. Stand-alone and child fonts can be closed but parent ones, can not as they have at least one dependency (a child).

Returns
  true on success or false on failure.

Note
  If you forget to close a Font, it will be automatically closed once the GDK is terminated.

## ◆ getCount()

Sint32 CRM64Pro::FontMgr::getCount | ( |  | ) | const
| override

Get number of loaded objects.

Returns
  The number of fonts.

## ◆ setName()

Sint32 CRM64Pro::FontMgr::setName | ( | Sint32 | idFont,
|  | const string & | sName )
| override

Change the object name.

Parameters

  idFont | Font id.
  sName | The name to give to the font e.g. 'myFont'. The object name must be unique and with a maximum size of 64 characters or will be truncated.

Returns
  0 on success, or a negative error code on failure.

## ◆ get() [2/2]

Font * CRM64Pro::FontMgr::get | ( | Sint32 | idFont | ) |

Get a pointer to the font using its handler.

Parameters

  idFont | Font id.

Returns
  nullptr The font was not found.
  A pointer to the font object.

## ◆ getBuiltin()

Sint32 CRM64Pro::FontMgr::getBuiltin | ( | const string & | sName | ) |

Get a built-in embedded font id using its name.

Supported names are:

- Arial10Black
- Arial10White
- Arial12Black
- Arial12White
- CourierNew10Black
- CourierNew10White
- CourierNew12Black
- CourierNew12White Internally built-in fonts are stored with the @c64/font/ prefix.
  Parameters

    sName | Embedded font short name.

  Returns
    A positive Font id on success, or a negative value if the name is not a built-in font or could not be loaded.

## ◆ child()

Sint32 CRM64Pro::FontMgr::child | ( | Sint32 | idFont | ) |

Create a child font dependant on the provided one (the parent).

A child font uses the attributes of the parent and creates also a parent child image for having different attributes.

Parameters

  idFont | Parent Font id. If the provided font is a child, internally it will redirect this request to the parent in order to create the new child.

Returns
  Greater than 0 on success (the Font id) or a negative error code on failure.

Note
  The child use the parent's name.

## ◆ load() [1/2]

Sint32 CRM64Pro::FontMgr::load | ( | const string & | sCDCFile,
|  | const string & | sName )

Load a font stored in a CDC file.

Parameters

  sCDCFile | String containing the [directory]+filename. Directory separators '\' and '/' are supported.
  sName | String with the font name (maximum size of 64 characters). If the font is already created, this method will call child() for creating a child.

Returns
  0 or greater on success (the Font id) or a negative error code on failure.

## ◆ load() [2/2]

Sint32 CRM64Pro::FontMgr::load | ( | const Sint32 | idCDC,
|  | const string & | sName )

Load a font stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | String with the font name (maximum size of 64 characters). If the font is already created, this method will call child() for creating a child.

Returns
  Greater than 0 on success (the Font id) or a negative error code on failure.

## ◆ loadFromBuffer()

Sint32 CRM64Pro::FontMgr::loadFromBuffer | ( | const void * | pBuffer,
|  | Sint32 | iSize,
|  | const string & | sName )

Load a font from an image memory buffer.

Parameters

  pBuffer | Pointer to the memory buffer containing the image (BMP or PNG) with transparency enabled.
  iSize | Size of the buffer in bytes.
  sName | string with the font name (max 64 characters).

Returns
  0 or greater on success (the Font id) or a negative error code on failure.

## ◆ remove()

Sint32 CRM64Pro::FontMgr::remove | ( | const Sint32 | idCDC,
|  | const string & | sName )

Remove a font stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | String with the font name (maximum size of 64 characters).

Returns
  Greater than 0 on success, or a negative error code on failure.

Note
  The font must be closed before trying to remove it from the CDC.

## ◆ exist() [1/2]

bool CRM64Pro::FontMgr::exist | ( | const Sint32 | idCDC,
|  | const string & | sName )

Check if a font is stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | string with the font name (maximum size of 64 characters).

Returns
  true on success (it exists) or false on failure (it does not exist).

## ◆ exist() [2/2]

bool CRM64Pro::FontMgr::exist | ( | const string & | sCDCFile,
|  | const string & | sName )

Check if a font is stored in a CDC file.

Parameters

  sCDCFile | Path to the CDC archive file.
  sName | string with the font name (maximum size of 64 characters).

Returns
  true on success (it exists) or false on failure (it does not exist).