Class: Font

Font(jbbInstance)

Represents a single font that can be loaded and used for drawing text.

Constructor

new Font(jbbInstance)

Parameters:
Name Type Description
jbbInstance object A reference to the main jBB class instance.
Source:

Classes

Font

Methods

height(valueopt) → {number}

Measures the height of a given string if it were drawn with this font.
Parameters:
Name Type Attributes Default Description
value string <optional>
"W" The string to measure.
Source:
Returns:
The height in pixels.
Type
number

(async) load(path, name)

Asynchronously loads the font file and makes it available for drawing.
Parameters:
Name Type Description
path string The path to the font file.
name string The CSS font-family name to assign.
Source:

set(size, boldopt, italicopt, weightopt)

Sets the current font style for subsequent text drawing operations.
Parameters:
Name Type Attributes Default Description
size number The font size in pixels.
bold boolean <optional>
false True to make the font bold.
italic boolean <optional>
false True to make the font italic.
weight number <optional>
0 An optional font weight (e.g., 700). Overrides `bold` if set.
Source:

text(xopt, yopt, value)

Draws text on the canvas using this font.
Parameters:
Name Type Attributes Default Description
x number <optional>
0 The x-coordinate to start drawing.
y number <optional>
0 The y-coordinate to start drawing.
value string The text to draw.
Source:

width(valueopt) → {number}

Measures the width of a given string if it were drawn with this font.
Parameters:
Name Type Attributes Default Description
value string <optional>
"W" The string to measure.
Source:
Returns:
The width in pixels.
Type
number