Text

Command:

text "text-to-draw" size

Parameters:

size:

Specifies the size of the text to be rendered.

text-to-draw:

The text string that needs to be displayed.

Description:

The text command displays the given text at the current cursor position, applying the specified size for rendering.

Example:

text "Hello, World!" 16
// Renders the text "Hello, World!" at the current draw cursor position with a font size of 16

Explanation:

In this example, the text "Hello, World!" is rendered at the current draw cursor position with a font size of 16. The text command allows for direct rendering of text strings on the screen.

Additionally, the text command can be used to set the font for subsequent text rendering by providing the URL or file path of a text file containing font data along with the setfont parameter. This command provides a simple and effective way to display text within the UI, allowing for customization of text appearance and font selection when needed.

Using the Font System

Changing Line Height

The line height can be adjusted using the configtext command with the lineheight parameter. The default line height is 23.

Example:

configtext "lineheight" 23
// Sets the line height to 23

Changing Character Spacing

The space between characters can be adjusted as a multiple of the size of the text using the configtext command with the spacing parameter.

Example:

configtext "spacing" 1
// Sets the spacing between characters to 1 times the size of the text

Selecting a Font

To select a font to use, use the configtext command with the usefont parameter and specify the font name.

Example:

configtext "usefont" "Llama"
// Selects the "Llama" font for text rendering

Loading a Font from a URL

To load a font from a URL, use the configtext command with the importfont parameter, specifying the font name and URL.

Example:

configtext "importfont" "CustomFont" "https://example.com/fonts/customfont.ojff"
// Loads the "CustomFont" from the specified URL

Reverting to Default Font

To revert to the default font, use the configtext command with the usedefault parameter.

Example:

configtext "usedefault"
// Reverts to the default font

Practical Examples

Rendering Text with Custom Font Size

To render text with a custom font size of 20:

text "Welcome to the system!" 20
// Renders the text "Welcome to the system!" with a font size of 20

Adjusting Line Height and Character Spacing

To set the line height to 30 and character spacing to 1.5 times the size of the text:

configtext "lineheight" 1.5
configtext "spacing" 1.5
// Sets the line height to 1.5x normal and character spacing to 1.5x the size of the text

Using a Custom Font

To use a custom font named "Roboto":

configtext "usefont" "Llama"
// Selects the "Llama" font for text rendering

Loading and Using a Font from a URL

To load a font from a URL and use it for rendering text:

configtext "importfont" "CoolFont" "https://example.com/fonts/coolfont.ojff"
configtext "usefont" "CoolFont"
// Loads the "CoolFont" from the specified URL and selects it for text rendering

Last updated