forked from DigiPen-Faculty/CProcessing
-
Notifications
You must be signed in to change notification settings - Fork 0
Font
Arthur edited this page Oct 25, 2021
·
1 revision
This section contains all functions relating to CP_Font.
Gets the default CP_Font used by CProcessing.
CP_Font CP_Font_GetDefault();
This function has no parameters
- CP_Font - The default font of CProcessing.
void update()
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 255, 255, 255));
CP_Font default = CP_Font_GetDefault();
}
Loads a CP_Font from the given filepath.
CP_Font CP_Font_Load(const char* filepath);
- filepath (const char*) - The filepath to the font that you want to load.
- CP_Font - The font loaded from the given filepath, will be NULL if no font could be loaded.
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);
}
Sets a given CP_Font as the font to use when drawing text.
void CP_Font_Set(CP_Font font);
- font (CP_Font) - The font that you want to use when drawing text.
This function does not return anything.
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);
}
Draws the given text to the screen using the current CP_Font.
void CP_Font_DrawText(const char* text, float x, float y);
- text (const char*) - The text you want to display on the screen.
- x (float) - The x position of the text.
- y (float) - The y position of the text.
This function does not return anything
#include <stdio.h>
#include <stdlib.h>
void update()
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 255, 255, 255));
CP_Settings_Fill(CP_Color_Create(0, 0, 0, 255));
CP_Settings_TextSize(20.0f);
char buffer[50] = { 0 };
sprintf_s(buffer, _countof(buffer), "Frame count: %i", CP_System_GetFrameCount());
CP_Font_DrawText(buffer, 30, 30);
CP_Font_DrawText("Hi Justin!", 100, 200);
}
Draws the given text onto the screen within a text box using the current CP_Font.
void CP_Font_DrawTextBox(const char* text, float x, float y, float rowWidth);
- text (const char*) - The text you want to display on the screen.
- x (float) - The x position of the text.
- y (float) - The y position of the text.
- rowWidth (float) - The width of each row.
This function does not return anything
void update()
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 255, 255, 255));
CP_Font_DrawTextBox("Hi Justin!", 100, 100, 20);
}