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

Loading...
Searching...
No Matches
CRM64Pro::FontMgrfinal
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.
Sint32 | 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 handle.
Sint32 | getBuiltin (const string &sName)
| Get a built-in embedded font id using its name.
Sint32 | child (Sint32 idFont)
| Create a child font dependent on the provided one (the parent).
Sint32 | load (const string &sCDCFile, const string &sName)
| Load a font stored in a CDC file.
Sint32 | load (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 (Sint32 idCDC, const string &sName)
| Remove a font stored in a CDC file.
bool | exists (Sint32 idCDC, const string &sName) const
| Check if a font is stored in a CDC file.
bool | exists (const string &sCDCFile, const string &sName) const
| 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
  Borrowed pointer to the Font object, or nullptr if not found.

Note
  The returned pointer must not be deleted. It remains valid until the Font is closed or FontMgr is reset or terminated.

## ◆ info()

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

Request Font Manager information.

Writes information to the default log.

Parameters

  iMode | -1 to display only manager information. 0 (default) to display manager and all objects. A specific Font ID displays manager information and only that Font.

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 creates an empty font with no image assigned. Use Font::assignImage() to assign the image.

Parameters

  sName | Font name, e.g. 'pFont'. Must be unique and shorter than 64 characters.
  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, the method leaves the current state unchanged and returns an error code.

## ◆ close()

Sint32 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 cannot as they have at least one dependency (a child).

Returns
  0 on success, or a negative error code 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 | Font name, e.g. 'pFont'. Must be unique and shorter than 64 characters.

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

Parameters

  idFont | Font id.

Returns
  Borrowed pointer to the Font object, or nullptr if not found.

Note
  The returned pointer must not be deleted. It remains valid until the Font is closed or FontMgr is reset or terminated.

## ◆ 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
    Greater than 0 on success (the Font id), or a negative error code on failure.

## ◆ child()

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

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

A child font uses the parent's attributes and creates a child image for 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 uses 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 (shorter than 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.

## ◆ load() [2/2]

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

Load a font stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | String with the font name (shorter than 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 (shorter than 64 characters).

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

## ◆ remove()

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

Remove a font stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | String with the font name (shorter than 64 characters).

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

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

## ◆ exists() [1/2]

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

Check if a font is stored in a CDC file.

Parameters

  idCDC | CDC id.
  sName | string with the font name (shorter than 64 characters).

Returns
  true if the resource is stored in the CDC file, or false otherwise. No error is reported.

## ◆ exists() [2/2]

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

Check if a font is stored in a CDC file.

Parameters

  sCDCFile | Path to the CDC archive file.
  sName | string with the font name (shorter than 64 characters).

Returns
  true if the resource is stored in the CDC file, or false otherwise. No error is reported.