GSDP:GAM100/CProcessing/CP Font

From Inside
Jump to: navigation, search

CP_Font

Description

CP_Font is a type that can be used to store loaded fonts and swap them out as needed. Calling the function CP_Font_Load() will load a font and CP_Font_Set() will set it as the current font. CP_Font_GetDefault() can be used in place of a CP_Font to re-select the default font.

Example

void update() 
{
  // Set the background color to blue
  CP_Settings_Background(CP_Color_Create(60, 120, 255, 255));

  // Load a font from the assets folder
  CP_Font font1 = CP_Font_Load("./Assets/Exo2-Regular.ttf");

  // Select it as the current font, setting the size to 36
  CP_Font_Set(font1, 36.0f);

  // Write "Hello, World!" at the mouse position
  CP_Text_DrawText("Hello, World!", CP_Input_GetMouseX(), CP_Input_GetMouseY());

  // Select the default font, size 36
  CP_Font_Set(CP_Font_GetDefault(), 36.0f);

  // Write "Hello, World!" at the point (25, 25)
  CP_Text_DrawText("Hello, World!", 25.0f, 25.0f);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>