![]() |
CRM64Pro GDK v0.17.0
A free cross-platform game development kit built on top of SDL 3.0
|
Font Object class.
Public Member Functions | |
| bool | info (Sint32 iMode=0) override |
| Request Font object information. | |
| const string & | getName () const override |
| Get the name. | |
| Uint32 | getID () const override |
| Get the ID. | |
| Sint32 | assignImage (Sint32 idImage, Sint32 iOwnership=0) |
| Assign an Image to this font. | |
| Sint32 | getImage () const |
| Get the assigned Image of this font. | |
| bool | setCursor (Uint8 cCursor) |
| Set cursor character. | |
| Uint8 | getCursor () const |
| Get cursor character. | |
| Sint32 | getCursorPositionByPixel (const string &sText, Sint32 iPixelPos) const |
| Get the cursor position given a number of pixels. | |
| bool | setKerning (Sint32 iKer) |
| Set the kerning value. | |
| Sint32 | getKerning () const |
| Get the kerning value. | |
| bool | setSpaceWidth (Sint32 iWidth) |
| Set the space character width. | |
| Sint32 | getSpaceWidth () const |
| Get the space character width. | |
| Sint32 | getWidth (const string &sText, Sint32 iCurPos=-1) const |
| Get the width of the given string (in pixels). | |
| Sint32 | getHeight () const |
| Get the height of this font (in pixels). | |
| bool | setPosition (const Position &posX, const Position &posY) |
| Set the font position. | |
| const Position & | getPositionX () const |
| Get the font X position. | |
| const Position & | getPositionY () const |
| Get the font Y position. | |
| Sint32 | render (const string &sText, Sint32 iCurShow=0, Sint32 iCurPos=-1, Sint32 idRes=0) |
| Render a text using this font. | |
| Sint32 | renderEx (const string &sText, Sint32 iCurShow=0, Sint32 iCurPos=-1, float fScaleX=1.0f, float fScaleY=1.0f, const double dAngle=0.0, const SDL_FPoint *poCenter=nullptr, const SDL_FlipMode rf=SDL_FLIP_NONE, Sint32 idRes=0) |
| Render a text using this font. | |
| Sint32 | save (const string &sCDCFile, const string &sResourceName="") |
| Save the font to a CDC file. | |
| Sint32 | save (const Sint32 idCDC, const string &sResourceName="") |
| Save the font to a CDC file. | |
|
override |
Request Font object information.
Writes information to the default log.
| iMode | Unused for the time being. |
|
override |
Get the name.
|
override |
Get the ID.
| Sint32 CRM64Pro::Font::assignImage | ( | Sint32 | idImage, |
| Sint32 | iOwnership = 0 ) |
Assign an Image to this font.
It is mainly used for associating an Image to the font when it is created via FontMgr::create().
| idImage | Image id with the whole characters set. They are identified using alpha channel so the image needs to have colorkey/alpha channel enabled. |
| iOwnership | 0 for creating our own copy of the image or any other value for taking the ownership of the image; in this case, the image can not be already owned by another item. By default it is set to 0. |
| Sint32 CRM64Pro::Font::getImage | ( | ) | const |
Get the assigned Image of this font.
| bool CRM64Pro::Font::setCursor | ( | Uint8 | cCursor | ) |
Set cursor character.
| cCursor | A printable ASCII character from '!' to '~'. |
| Uint8 CRM64Pro::Font::getCursor | ( | ) | const |
Get cursor character.
| Sint32 CRM64Pro::Font::getCursorPositionByPixel | ( | const string & | sText, |
| Sint32 | iPixelPos ) const |
Get the cursor position given a number of pixels.
| sText | String to get the cursor position. |
| iPixelPos | Pixel position to convert to cursor position. |
| bool CRM64Pro::Font::setKerning | ( | Sint32 | iKer | ) |
Set the kerning value.
| iKer | Signed integer added to the fixed character gap in pixels. |
| Sint32 CRM64Pro::Font::getKerning | ( | ) | const |
Get the kerning value.
| bool CRM64Pro::Font::setSpaceWidth | ( | Sint32 | iWidth | ) |
Set the space character width.
| iWidth | Space width in pixels. Use 0 to keep the automatic width derived from the assigned image. |
| Sint32 CRM64Pro::Font::getSpaceWidth | ( | ) | const |
Get the space character width.
| Sint32 CRM64Pro::Font::getWidth | ( | const string & | sText, |
| Sint32 | iCurPos = -1 ) const |
Get the width of the given string (in pixels).
| sText | String to get its width. |
| iCurPos | Up to this byte position. By default, it is set to -1 for positioning the cursor at the end of the string. |
| Sint32 CRM64Pro::Font::getHeight | ( | ) | const |
Get the height of this font (in pixels).
Set the font position.
| posX | Position struct with X position. Can be absolute (float) or use position helpers from ::ePositionHelpers enum. |
| posY | Position struct with Y position. Can be absolute (float) or use position helpers from ::ePositionHelpers enum. |
| const Position & CRM64Pro::Font::getPositionX | ( | ) | const |
Get the font X position.
| const Position & CRM64Pro::Font::getPositionY | ( | ) | const |
Get the font Y position.
| Sint32 CRM64Pro::Font::render | ( | const string & | sText, |
| Sint32 | iCurShow = 0, | ||
| Sint32 | iCurPos = -1, | ||
| Sint32 | idRes = 0 ) |
Render a text using this font.
| sText | String with the text to be rendered. |
| iCurShow | 0 to hide the cursor or any other value to show it. By default it is hidden. |
| iCurPos | Byte position of the cursor on the given text. By default it is set to -1 which means at the end. |
| idRes | A valid screen or image handle. By default it tries to use the default screen. |
| Sint32 CRM64Pro::Font::renderEx | ( | const string & | sText, |
| Sint32 | iCurShow = 0, | ||
| Sint32 | iCurPos = -1, | ||
| float | fScaleX = 1.0f, | ||
| float | fScaleY = 1.0f, | ||
| const double | dAngle = 0.0, | ||
| const SDL_FPoint * | poCenter = nullptr, | ||
| const SDL_FlipMode | rf = SDL_FLIP_NONE, | ||
| Sint32 | idRes = 0 ) |
Render a text using this font.
| sText | String with the text to be rendered. |
| iCurShow | 0 to hide the cursor or any other value to show it. By default it is hidden. |
| iCurPos | Byte position of the cursor on the given text. By default it is set to -1 which means at the end. |
| fScaleX | X scaling factor. |
| fScaleY | Y scaling factor. |
| dAngle | An angle in degrees that indicates the rotation that will be applied. |
| poCenter | SDL_FPoint pointer indicating the point around which each character will be rotated. By default, it is set to nullptr and the rotation will be done around rDst.w/2 and rDst.h/2. |
| rf | SDL_FlipMode value stating which flipping actions should be performed. |
| idRes | A valid screen or image handle. By default it tries to use the default screen. |
| Sint32 CRM64Pro::Font::save | ( | const string & | sCDCFile, |
| const string & | sResourceName = "" ) |
Save the font to a CDC file.
The associated image will also be saved in to the same CDC file.
| sCDCFile | String containing the [directory]+filename+[extension]. Directory separators '\' and '/' are supported. |
| sResourceName | Optional resource name to use in the CDC. If empty (default), uses the Font object's internal name. |
| Sint32 CRM64Pro::Font::save | ( | const Sint32 | idCDC, |
| const string & | sResourceName = "" ) |
Save the font to a CDC file.
The associated image will also be saved in to the same CDC file.
| idCDC | CDC id. |
| sResourceName | Optional resource name to use in the CDC. If empty (default), uses the Font object's internal name. |