Skip to content

ax.util

Source: gamemode/framework/util/util_text.lua

Utility helpers used across the Parallax framework (printing, file handling, text utilities, etc.).

Section: text_utilities

Documented functions: 6

Functions


ax.util:CapText(text, maxLength)

Utility helpers used across the Parallax framework (printing, file handling, text utilities, etc.). Text utilities. Cap text to a maximum number of characters, adding ellipsis when trimmed.

Parameters

Name Type Description
text string Text to cap
maxLength number Maximum number of characters

Returns

  • string: The truncated text (with ellipsis when trimmed)

Usage

local short = ax.util:CapText(longText, 32)

ax.util:CapTextWord(text, maxLength)

Cap text at a word boundary to avoid breaking words when truncating.

Parameters

Name Type Description
text string Text to cap
maxLength number Maximum number of characters

Returns

  • string: The truncated text at a word boundary

Usage

local short = ax.util:CapTextWord(longText, 50)

ax.util:GetTextHeight(font)

Returns the given text's height (client-only).

Parameters

Name Type Description
font string Font name

Returns

  • number: Height in pixels

Usage

local h = ax.util:GetTextHeight("Default")

ax.util:GetTextSize(font, text)

Returns the given text's size (client-only).

Parameters

Name Type Description
font string Font name
text string Text to measure

Returns

  • number: w, number h Width and height in pixels

Usage

local w,h = ax.util:GetTextSize("Default", "Hello")

ax.util:GetTextWidth(font, text)

Returns the given text's width (client-only).

Parameters

Name Type Description
font string Font name
text string Text to measure

Returns

  • number: Width in pixels

Usage

local w = ax.util:GetTextWidth("Default", "Hello")

ax.util:GetWrappedText(text, font, maxWidth)

Wraps text into multiple lines based on a maximum width (client-only).

Parameters

Name Type Description
text string Text to wrap
font string Font name used to measure text
maxWidth number Maximum width in pixels

Returns

  • table: An array of line strings

Usage

local lines = ax.util:GetWrappedText("Hello world", "Default", 200)