Font - Polkm105/DesignPatternPractice GitHub Wiki
COMPLETE
This section contains all functions relating to CP_Font
Table Of Contents
CP_Font_GetDefault
Gets the default CP_Font of C-Processing.
Function
CP_Font CP_Font_GetDefault();
Parameters
This function has no parameters
Return
- CP_Font - The default font of C-Processing
Example
void init()
{
}
void update()
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 255, 255, 255));
CP_Font default = CP_Font_GetDefault();
}
void shutdown()
{
}
Related
CP_Font_Load
Loads a CP_Font from the given filepath.
Function
CP_Font CP_Font_Load(const char* filepath);
Parameters
- filepath (const char*) - The filepath to the font that you want to load
Return
- CP_Font - The font loaded from the given filepath, is NULL if no font could be loaded
Example
CP_Font myFont;
void init()
{
myFont = CP_Font_Load("Assets/Justins_Font.ttf");
}
void update()
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 255, 255, 255));
CP_Font_Set(myFont);
CP_Font_DrawText("Hi Justin!", 100, 100);
}
void shutdown()
{
CP_Font_Free(myFont);
}
Related
CP_Font_Set
Sets a given CP_Font as the font to use when drawing text.
Function
void CP_Font_Set(CP_Font font);
Parameters
- font (CP_Font) - The font that you want to use when drawing text
Return
This function does not return anything
Example
CP_Font myFont;
void init()
{
myFont = CP_Font_Load("Assets/Justins_Font.ttf");
}
void update()
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 255, 255, 255));
CP_Font_Set(myFont);
CP_Font_DrawText("Hi Justin!", 100, 100);
}
void shutdown()
{
CP_Font_Free(myFont);
}
Related
CP_Font_DrawText
Draws the given text to the screen using the current CP_Font.
Function
void CP_Font_DrawText(const char* text, float x, float y);
Parameters
- text (const char*) - The text you want to display on the screen
- x (float) - The x position of the center of the text
- y (float) - The y position of the center of the text
Return
This function does not return anything
Example
CP_Font myFont;
void init()
{
myFont = CP_Font_Load("Assets/Justins_Font.ttf");
}
void update()
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 255, 255, 255));
CP_Font_Set(myFont);
CP_Font_DrawText("Hi Justin!", 100, 100);
}
void shutdown()
{
CP_Font_Free(myFont);
}
Related
CP_Font_DrawTextBox
Draws the given text onto the screen within a text box using the current CP_Font.
Function
void CP_Font_DrawTextBox(const char* text, float x, float y, float rowWidth);
Parameters
- text (const char*) - The text you want to display on the screen
- x (float) - The x position of the center of the text
- y (float) - The y position of the center of the text
- rowWidth (float) - The width of each row
Return
This function does not return anything
Example
CP_Font myFont;
void init()
{
myFont = CP_Font_Load("Assets/Justins_Font.ttf");
}
void update()
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 255, 255, 255));
CP_Font_Set(myFont);
CP_Font_DrawTextBox("Hi Justin!", 100, 100, 20);
}
void shutdown()
{
CP_Font_Free(myFont);
}