GSDP:GAM100/CProcessing/PFont

From Inside
Jump to: navigation, search

PFont

Description

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

Example

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

    // Load a font from the assets folder
    PFont font1 = loadFont("./Assets/Exo2-Regular.ttf");
    
    // Select it as the current font, setting the size to 36
    textFont(font1, 36.0f);

    // Write "Hello, World!" at the mouse position
    text("Hello, World!", mouseX, mouseY);

    // Select the default font, size 36
    textFont(defaultFont, 36.0f);

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

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>