Cavestory Mod API
Macros | Typedefs | Functions | Variables
Fonts

Stencil 72!!! More...

Macros

#define FONT_OBJECT_SIZE   1040
 Do not change.
 
#define TEXT_SIZE(font_object, string, ptr_x, ptr_y)   GetTextSize(font_object, string, strlen(string), &ptr_x, &ptr_y); ptr_x /= magnification; ptr_y /= magnification;
 Get the rendered size of a string.
 
#define TEXT_SIZE_2(font_object, string, string_length, ptr_x, ptr_y)   GetTextSize(font_object, string, string_length, &ptr_x, &ptr_y); ptr_x /= magnification; ptr_y /= magnification;
 Get the rendered size of a string and automatically divide it by the current global magnification level.
 
#define TEXT_WIDTH(font_object, string)   (GetTextWidth(font_object, string) / magnification)
 Get the rendered width of a string.
 
#define TEXT_HEIGHT(font_object, string)   (GetTextHeight(font_object, string) / magnification)
 Get the rendered height of a string.
 
#define TEXT_WIDTH_2(font_object, string, string_length)   (GetTextWidth(font_object, string, string_length) / magnification)
 Get the rendered width of a string and automatically divide it by the current global magnification level.
 
#define TEXT_HEIGHT_2(font_object, string, string_length)   (GetTextHeight(font_object, string, string_length) / magnification)
 Get the rendered height of a string and automatically divide it by the current global magnification level.
 
#define TEXT_WIDTH_2S(font_object, string)   (GetTextWidth(font_object, string, strlen(string)) / magnification)
 Get the rendered width of a string, automatically divide it by the current global magnification level, and automatically calculate the string length.
 
#define TEXT_HEIGHT_2S(font_object, string)   (GetTextHeight(font_object, string, strlen(string)) / magnification)
 Get the rendered height of a string, automatically divide it by the current global magnification level, and automatically calculate the string length.
 
#define FONT_ASCII_HEIGHT(font_object)   (GetTextHeight(font_object, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") / magnification)
 Get the base height for a font.
 
#define UI_TEXT_SIZE(font_object, string, ptr_x, ptr_y)   GetTextSize(font_object, string, strlen(string), &ptr_x, &ptr_y); ptr_x /= CSM_GetUIMagnificationLevel(); ptr_y /= CSM_GetUIMagnificationLevel();
 Get the rendered size of a string.
 
#define UI_TEXT_SIZE_2(font_object, string, string_length, ptr_x, ptr_y)   GetTextSize(font_object, string, string_length, &ptr_x, &ptr_y); ptr_x /= CSM_GetUIMagnificationLevel(); ptr_y /= CSM_GetUIMagnificationLevel();
 Get the rendered size of a string and automatically divide it by the current global magnification level.
 
#define UI_TEXT_WIDTH(font_object, string)   (GetTextWidth(font_object, string) / CSM_GetUIMagnificationLevel())
 Get the rendered width of a string.
 
#define UI_TEXT_HEIGHT(font_object, string)   (GetTextHeight(font_object, string) / CSM_GetUIMagnificationLevel())
 Get the rendered height of a string.
 
#define UI_TEXT_WIDTH_2(font_object, string, string_length)   (GetTextWidth(font_object, string, string_length) / CSM_GetUIMagnificationLevel())
 Get the rendered width of a string and automatically divide it by the current global magnification level.
 
#define UI_TEXT_HEIGHT_2(font_object, string, string_length)   (GetTextHeight(font_object, string, string_length) / CSM_GetUIMagnificationLevel())
 Get the rendered height of a string and automatically divide it by the current global magnification level.
 
#define UI_TEXT_WIDTH_2S(font_object, string)   (GetTextWidth(font_object, string, strlen(string)) / CSM_GetUIMagnificationLevel())
 Get the rendered width of a string, automatically divide it by the current global magnification level, and automatically calculate the string length.
 
#define UI_TEXT_HEIGHT_2S(font_object, string)   (GetTextHeight(font_object, string, strlen(string)) / CSM_GetUIMagnificationLevel())
 Get the rendered height of a string, automatically divide it by the current global magnification level, and automatically calculate the string length.
 
#define UI_FONT_ASCII_HEIGHT(font_object)   (GetTextHeight(font_object, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") / CSM_GetUIMagnificationLevel())
 Get the base height for a font.
 
#define CUSTOMMAG_TEXT_SIZE(INPUT_MAG, font_object, string, ptr_x, ptr_y)   GetTextSize(font_object, string, strlen(string), &ptr_x, &ptr_y); ptr_x /= INPUT_MAG; ptr_y /= INPUT_MAG;
 Get the rendered size of a string.
 
#define CUSTOMMAG_TEXT_SIZE_2(INPUT_MAG, font_object, string, string_length, ptr_x, ptr_y)   GetTextSize(font_object, string, string_length, &ptr_x, &ptr_y); ptr_x /= INPUT_MAG; ptr_y /= INPUT_MAG;
 Get the rendered size of a string and automatically divide it by the current global magnification level.
 
#define CUSTOMMAG_TEXT_WIDTH(INPUT_MAG, font_object, string)   (GetTextWidth(font_object, string) / INPUT_MAG)
 Get the rendered width of a string.
 
#define CUSTOMMAG_TEXT_HEIGHT(INPUT_MAG, font_object, string)   (GetTextHeight(font_object, string) / INPUT_MAG)
 Get the rendered height of a string.
 
#define CUSTOMMAG_TEXT_WIDTH_2(INPUT_MAG, font_object, string, string_length)   (GetTextWidth(font_object, string, string_length) / INPUT_MAG)
 Get the rendered width of a string and automatically divide it by the current global magnification level.
 
#define CUSTOMMAG_TEXT_HEIGHT_2(INPUT_MAG, font_object, string, string_length)   (GetTextHeight(font_object, string, string_length) / INPUT_MAG)
 Get the rendered height of a string and automatically divide it by the current global magnification level.
 
#define CUSTOMMAG_TEXT_WIDTH_2S(INPUT_MAG, font_object, string)   (GetTextWidth(font_object, string, strlen(string)) / INPUT_MAG)
 Get the rendered width of a string, automatically divide it by the current global magnification level, and automatically calculate the string length.
 
#define CUSTOMMAG_TEXT_HEIGHT_2S(INPUT_MAG, font_object, string)   (GetTextHeight(font_object, string, strlen(string)) / INPUT_MAG)
 Get the rendered height of a string, automatically divide it by the current global magnification level, and automatically calculate the string length.
 
#define CUSTOMMAG_FONT_ASCII_HEIGHT(INPUT_MAG, font_object)   (GetTextHeight(font_object, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") / INPUT_MAG)
 Get the base height for a font.
 

Typedefs

typedef struct FontObject FontObject
 

Functions

CAVESTORY_MOD_API int CSM_GetUIMagnificationLevel ()
 Get the current UI magnification. More...
 
CAVESTORY_MOD_API int CSM_GetChatMagnificationLevel ()
 Get the current chat magnification. More...
 
CAVESTORY_MOD_API void SetFontCharacterWhitelist (const unsigned char *pWhitelist)
 Set a whitelist for the rendering system. More...
 
CAVESTORY_MOD_API void SetFontWhitelistEnabled (bool bEnabled)
 Set whether the whitelist is active or not. More...
 
CAVESTORY_MOD_API const unsigned char * GetFontCharacterWhitelist ()
 Get the current font whitelist. More...
 
CAVESTORY_MOD_API FontObject * LoadFontFromFile (const char *pFileName, unsigned int cell_width, unsigned int cell_height, VideoTexture *pTexture=NULL, FontManager *pManager=NULL)
 Load a font object from a file. More...
 
CAVESTORY_MOD_API void SetFontTexture (FontObject *pFont, VideoTexture *pTexture)
 Link a font to a texture. More...
 
CAVESTORY_MOD_API FontObject * LoadFontFromData (const unsigned char *data, size_t data_size, unsigned int cell_width, unsigned int cell_height, VideoTexture *pTexture=NULL, FontManager *pManager=NULL)
 Load a font object from data. More...
 
CAVESTORY_MOD_API FontObject * LoadFont (const char *font_filename, unsigned int cell_width, unsigned int cell_height, VideoTexture *pTexture=NULL, FontManager *pManager=NULL)
 Load a font from Windows. More...
 
CAVESTORY_MOD_API void GetTextSize (FontObject *font_object, const char *string, size_t string_length, int *size_x, int *size_y)
 Get the rendered size of text. More...
 
CAVESTORY_MOD_API unsigned int GetTextWidth (FontObject *font_object, const char *string, size_t string_length=size_t(-1))
 Get the rendered width of text. More...
 
CAVESTORY_MOD_API unsigned int GetTextHeight (FontObject *font_object, const char *string, size_t string_length=size_t(-1))
 Get the rendered height of text. More...
 
CAVESTORY_MOD_API BOOL IsFontLinkedToTexture (FontObject *font_object, VideoTexture *pTexture)
 Check to see if a font is linked with a texture. More...
 
CAVESTORY_MOD_API int GetFontMagnification (FontObject *font_object)
 Get the magnification level of a font object. More...
 
CAVESTORY_MOD_API int GetFontHeight (FontObject *font_object)
 Get the general render height of a font. More...
 
CAVESTORY_MOD_API void DrawNormalText (FontObject *font_object, unsigned char *bitmap_buffer, size_t bitmap_pitch, int bitmap_width, int bitmap_height, int x, int y, unsigned long colour, const char *string, size_t string_length)
 Draw normal text onto a bitmap. More...
 
CAVESTORY_MOD_API void DrawClippedText (FontObject *font_object, unsigned char *bitmap_buffer, size_t bitmap_pitch, int bitmap_width, int bitmap_height, int x, int y, unsigned long colour, const char *string, size_t string_length, int clipLEFT, int clipTOP, int clipRIGHT, int clipBOTTOM, float iOutAlpha=1.f)
 Draw clipped text onto a bitmap. More...
 
CAVESTORY_MOD_API void UnloadFont (FontObject *font_object)
 Unload a font object. More...
 
CAVESTORY_MOD_API unsigned long UTF8ToUnicode (const unsigned char *string, unsigned int *bytes_read)
 Convert UTF8 to unicode. More...
 
CAVESTORY_MOD_API void InitFont ()
 Do not use.
 
CAVESTORY_MOD_API void DeInitFont ()
 Do not use.
 

Variables

class CAVESTORY_MOD_API FontManager
 

Detailed Description

Stencil 72!!!

Font manipulation.

Function Documentation

◆ CSM_GetChatMagnificationLevel()

CAVESTORY_MOD_API int CSM_GetChatMagnificationLevel ( )

Get the current chat magnification.

Returns
Returns the desired chat magnification level.

◆ CSM_GetUIMagnificationLevel()

CAVESTORY_MOD_API int CSM_GetUIMagnificationLevel ( )

Get the current UI magnification.

Returns
Returns the desired UI magnification level.

◆ DrawClippedText()

CAVESTORY_MOD_API void DrawClippedText ( FontObject *  font_object,
unsigned char *  bitmap_buffer,
size_t  bitmap_pitch,
int  bitmap_width,
int  bitmap_height,
int  x,
int  y,
unsigned long  colour,
const char *  string,
size_t  string_length,
int  clipLEFT,
int  clipTOP,
int  clipRIGHT,
int  clipBOTTOM,
float  iOutAlpha = 1.f 
)

Draw clipped text onto a bitmap.

Parameters
font_objectThe font to use.
bitmap_bufferThe buffer to draw to.
bitmap_pitchThe pitch of the bitmap buffer.
bitmap_widthThe width of the bitmap.
bitmap_heightThe height of the bitmap.
xThe X position of where to draw the text at.
yThe Y position of where to draw the text at.
colourThe color of the string.
stringThe string to be drawn.
string_lengthThe length of the string.
clipLEFTThe left clipping position.
clipTOPThe top clipping position.
clipRIGHTThe right clipping position.
clipBOTTOMThe bottom clipping position.
iOutAlphaThe transparency value of the text.
See also
CSM_RGB
CSM_RGBA

◆ DrawNormalText()

CAVESTORY_MOD_API void DrawNormalText ( FontObject *  font_object,
unsigned char *  bitmap_buffer,
size_t  bitmap_pitch,
int  bitmap_width,
int  bitmap_height,
int  x,
int  y,
unsigned long  colour,
const char *  string,
size_t  string_length 
)

Draw normal text onto a bitmap.

Parameters
font_objectThe font to use.
bitmap_bufferThe buffer to draw to.
bitmap_pitchThe pitch of the bitmap buffer.
bitmap_widthThe width of the bitmap.
bitmap_heightThe height of the bitmap.
xThe X position of where to draw the text at.
yThe Y position of where to draw the text at.
colourThe color of the string.
stringThe string to be drawn.
string_lengthThe length of the string.
See also
CSM_RGB
CSM_RGBA
Deprecated:

◆ GetFontCharacterWhitelist()

CAVESTORY_MOD_API const unsigned char* GetFontCharacterWhitelist ( )

Get the current font whitelist.

Returns
Returns the current font whitelist.

◆ GetFontHeight()

CAVESTORY_MOD_API int GetFontHeight ( FontObject *  font_object)

Get the general render height of a font.

Parameters
font_objectThe font to use.
Returns
Returns the height of the provided font.

◆ GetFontMagnification()

CAVESTORY_MOD_API int GetFontMagnification ( FontObject *  font_object)

Get the magnification level of a font object.

Parameters
font_objectThe font to check.
Returns
Returns the font's current magnification level.

◆ GetTextHeight()

CAVESTORY_MOD_API unsigned int GetTextHeight ( FontObject *  font_object,
const char *  string,
size_t  string_length = size_t(-1) 
)

Get the rendered height of text.

Parameters
font_objectThe font to size the text up with.
stringThe string to be sized.
string_lengthThe length of the string.
Returns
Returns the height of the string.

◆ GetTextSize()

CAVESTORY_MOD_API void GetTextSize ( FontObject *  font_object,
const char *  string,
size_t  string_length,
int *  size_x,
int *  size_y 
)

Get the rendered size of text.

Parameters
font_objectThe font to size the text up with.
stringThe string to be sized.
string_lengthThe length of the string.
size_xA pointer to an int to hold the resulting width. Can be NULL.
size_yA pointer to an int to hold the resulting height. Can be NULL.

◆ GetTextWidth()

CAVESTORY_MOD_API unsigned int GetTextWidth ( FontObject *  font_object,
const char *  string,
size_t  string_length = size_t(-1) 
)

Get the rendered width of text.

Parameters
font_objectThe font to size the text up with.
stringThe string to be sized.
string_lengthThe length of the string.
Returns
Returns the width of the string.

◆ IsFontLinkedToTexture()

CAVESTORY_MOD_API BOOL IsFontLinkedToTexture ( FontObject *  font_object,
VideoTexture pTexture 
)

Check to see if a font is linked with a texture.

Parameters
font_objectThe font to check.
pTextureThe texture to check against.
Returns
Returns true if the font is linked to the provided texture, false otherwise.

◆ LoadFont()

CAVESTORY_MOD_API FontObject* LoadFont ( const char *  font_filename,
unsigned int  cell_width,
unsigned int  cell_height,
VideoTexture pTexture = NULL,
FontManager pManager = NULL 
)

Load a font from Windows.

Parameters
font_filenameThe font's facename.
cell_widthThe width of the font.
cell_heightThe height of the font.
pTextureThe texture to force this font to use.
pManagerDo not use this param.
Returns
Returns a font object on success, NULL on fail. @warn This does not work the same on all computers.

◆ LoadFontFromData()

CAVESTORY_MOD_API FontObject* LoadFontFromData ( const unsigned char *  data,
size_t  data_size,
unsigned int  cell_width,
unsigned int  cell_height,
VideoTexture pTexture = NULL,
FontManager pManager = NULL 
)

Load a font object from data.

Parameters
dataThe data buffer.
data_sizeThe size of the data buffer.
cell_widthThe width of the font.
cell_heightThe height of the font.
pTextureThe texture to force this font to use.
pManagerDo not use this param.
Returns
Returns a font object on success, NULL on fail.

◆ LoadFontFromFile()

CAVESTORY_MOD_API FontObject* LoadFontFromFile ( const char *  pFileName,
unsigned int  cell_width,
unsigned int  cell_height,
VideoTexture pTexture = NULL,
FontManager pManager = NULL 
)

Load a font object from a file.

Parameters
pFileNameThe file name.
cell_widthThe width of the font.
cell_heightThe height of the font.
pTextureThe texture to force this font to use.
pManagerDo not use this param.
Returns
Returns a font object on success, NULL on fail.

◆ SetFontCharacterWhitelist()

CAVESTORY_MOD_API void SetFontCharacterWhitelist ( const unsigned char *  pWhitelist)

Set a whitelist for the rendering system.

Specifying a whitelist will tell the renderer to not draw any characters not included in said whitelist.

Parameters
pWhitelistThe whitelist. Can be NULL to disable the whitelist.

◆ SetFontTexture()

CAVESTORY_MOD_API void SetFontTexture ( FontObject *  pFont,
VideoTexture pTexture 
)

Link a font to a texture.

Parameters
pFontThe font to link.
pTextureThe texture to force this font to use.

◆ SetFontWhitelistEnabled()

CAVESTORY_MOD_API void SetFontWhitelistEnabled ( bool  bEnabled)

Set whether the whitelist is active or not.

Parameters
bEnabledWhether the whitelist should be enabled or not.
See also
SetFontCharacterWhitelist

◆ UnloadFont()

CAVESTORY_MOD_API void UnloadFont ( FontObject *  font_object)

Unload a font object.

Parameters
font_objectThe object to unload.

◆ UTF8ToUnicode()

CAVESTORY_MOD_API unsigned long UTF8ToUnicode ( const unsigned char *  string,
unsigned int *  bytes_read 
)

Convert UTF8 to unicode.

Parameters
stringThe string to convert.
bytes_readPointer to an int that will specify how many unicode bytes were read from the source string.
Returns
Returns the last character processed.