Font
Describes a font as defined in a data file, can be used to draw text on the screen.
Members
-
const Font@
bold
— The bold variant for this font, if specified. Null otherwise.
-
const Font@
italic
— The italic variant for this font, if specified. Null otherwise.
Methods
-
vec2i
getDimension(
string&
text
) const
-
vec2i
getDimension(
int
c,
int
lastC
) const
-
uint
getBaseline(
) const
-
uint
getLineHeight(
) const
-
void
draw(
vec2i&
pos,
string&
text
) const
-
void
draw(
vec2i&
pos,
string&
text,
Color&
color
) const
-
vec2i
draw(
vec2i&
pos,
int
c,
int
lastC,
Color&
color
) const
-
void
draw(
recti&
pos,
string&
text,
string&
ellipsis = locale::ELLIPSIS,
Color&
color = colors::White,
double
horizAlign = 0,
double
vertAlign = 0.5
) const
-
void
draw(
recti&
pos,
string&
text,
Color&
stroke,
string&
ellipsis = locale::ELLIPSIS,
Color&
color = colors::White,
double
horizAlign = 0,
double
vertAlign = 0.5,
int
strokeWidth = 1
) const
-
vec2i
draw(
recti&
pos,
vec2i&
offset,
int
lineHeight,
string&
text,
Color&
color,
bool
preserveLineHeight = false
) const
-
vec2i
getEndPosition(
recti&
pos,
vec2i&
offset,
int
lineHeight,
string&
text,
bool
preserveLineHeight = false
) const
vec2i
getDimension(
string&
text
) const
Calculate the amount of space needed to draw a string with this font.
-
string&
text — Text to calculate for.
Returns
vec2i
: Amount of space needed.
vec2i
getDimension(
int
c,
int
lastC
) const
Calculate the amount of space needed to draw a character with kerning.
-
int
c — Character to calculate for.
-
int
lastC — Previous character to kern with.
Returns
vec2i
: Amount of space needed.
vec2i
draw(
vec2i&
pos,
int
c,
int
lastC,
Color&
color
) const
Draw a character on screen using kerning with the previous character.
-
vec2i&
pos — Position to draw the character at.
-
int
c — Character to draw.
-
int
lastC — Character previously drawn before it. (Character will be kerned with respect to it)
-
Color&
color — Color to draw the character in.
Returns
vec2i
: The size of the area the character was drawn in.
void
draw(
recti&
pos,
string&
text,
string&
ellipsis = locale::ELLIPSIS,
Color&
color = colors::White,
double
horizAlign = 0,
double
vertAlign = 0.5
) const
Draw text on screen with this font, appending an ellipsis if the text is too long.
-
recti&
pos — Box to draw the text inside.
-
string&
text — Text to draw.
-
string&
ellipsis — Ellipsis to append to text.
-
Color&
color — Color to draw the text in.
-
double
horizAlign — Horizontal alignment within the box.
-
double
vertAlign — Vertical alignment within the box.
void
draw(
recti&
pos,
string&
text,
Color&
stroke,
string&
ellipsis = locale::ELLIPSIS,
Color&
color = colors::White,
double
horizAlign = 0,
double
vertAlign = 0.5,
int
strokeWidth = 1
) const
Draw text on screen with this font, appending an ellipsis if the text is too long.
-
recti&
pos — Box to draw the text inside.
-
string&
text — Text to draw.
-
Color&
stroke — Color of the stroke.
-
string&
ellipsis — Ellipsis to append to text.
-
Color&
color — Color to draw the text in.
-
double
horizAlign — Horizontal alignment within the box.
-
double
vertAlign — Vertical alignment within the box.
-
int
strokeWidth — Width of the stroke.
vec2i
draw(
recti&
pos,
vec2i&
offset,
int
lineHeight,
string&
text,
Color&
color,
bool
preserveLineHeight = false
) const
Draw text on screen with this font, word wrapping within the area.
-
recti&
pos — Box to draw the text inside.
-
vec2i&
offset — Offset of the first line of text in the box.
-
int
lineHeight — Height of each drawn line.
-
string&
text — Text to draw.
-
Color&
color — Color to draw the text in.
-
bool
preserveLineHeight — Whether lines after the first line should not reset the lineheight.
Returns
vec2i
: Dimensions of the text that was drawn.
vec2i
getEndPosition(
recti&
pos,
vec2i&
offset,
int
lineHeight,
string&
text,
bool
preserveLineHeight = false
) const
Get the position the cursor would end up at after drawing this text with word wrap.
-
recti&
pos — Box to draw the text inside.
-
vec2i&
offset — Offset of the first line of text in the box.
-
int
lineHeight — Height of each drawn line.
-
string&
text — Text to draw.
-
bool
preserveLineHeight — Whether lines after the first line should not reset the lineheight.
Returns
vec2i
: Dimension of the text that would be drawn.