Skip to content

Text

const text = require("@vectarine/text")
export type FontResource = ...
FontResource:drawText(text: string, pos: Pos, size: Size, color: Vec4.Vec4?): ()

Draws text at (x,y) with given font, size and color size is the maximum height that a text of that font will take on the screen If size is a number, it is in OpenGL coordinate (2 = height of the screen) If size is a ScreenVec, only the y component is used This is sometimes called the line height.

FontResource:measureText(
text: string,
size: Size,
): { width: number, height: number, bearingY: number }

Measures how much space the text will take when drawn height will always be less than size. bearingY will always be less than height. This is the distance from the top of the text to the baseline.

type Pos = ...
type Size = ...
text.font = ...

The default font (Roboto) you can use to draw without needed to load a .ttf file It is not a true resource and is always loaded.