fivem-ts

a library to speed up the development of Fivem scripts and frameworks


Project maintained by Purpose-Dev Hosted on GitHub Pages — Theme by mattgraham

fivem-ts - Documentation v0.7.5Docs


fivem-ts - Documentation v0.7.5 / Client / Text

Class: Text

The Text class is responsible for rendering text on the screen in FiveM. It provides several customization options including font, color, alignment, and more.

Example usage:

import { Text } from 'fivem-ts/client/ui';
import { Point, Color } from 'fivem-ts/client/utils';
import { Font, Alignment } from 'fivem-ts/client/enums';

const myText = new Text(
    'Hello, World!',
    new Point(500, 500),
    1.5,
    new Color(255, 0, 0, 255),
    Font.ChaletLondon,
    Alignment.Centered,
    true,
    true,
);

myText.draw();

Implements

Constructors

new Text()

new Text(caption, pos, scale, color, font, alignment, dropShadow, outline, wordWrap?): Text

Parameters

caption: string

Text to display

pos: Point

Position of text relative to alignment. In pixels.

scale: number = 1

Size of text. Default 1.0

color: Color = Color.white

Color of text. Default black.

font: Font = Font.ChaletLondon

Font of text. Default Chalet London.

alignment: Alignment = Alignment.Left

Alignment of text. Default Left.

dropShadow: boolean = false

outline: boolean = false

wordWrap?: Size

Returns

Text

Defined in

client/ui/Text.ts:55

Properties

alignment

alignment: Alignment

Defined in

client/ui/Text.ts:37


caption

caption: string

Defined in

client/ui/Text.ts:32


color

color: Color

Implementation of

IDrawable.color

Defined in

client/ui/Text.ts:35


dropShadow

dropShadow: boolean

Defined in

client/ui/Text.ts:38


font

font: Font

Defined in

client/ui/Text.ts:36


outline

outline: boolean

Defined in

client/ui/Text.ts:39


pos

pos: Point

Implementation of

IDrawable.pos

Defined in

client/ui/Text.ts:33


scale

scale: number

Defined in

client/ui/Text.ts:34


size

size: Size

Implementation of

IDrawable.size

Defined in

client/ui/Text.ts:41


wordWrap

wordWrap: Size

Defined in

client/ui/Text.ts:40

Methods

draw()

draw(offset, resolution)

draw(offset?, resolution?): void

Draws the text on the screen with the specified properties.

This method can be used to draw text with specific parameters or by using the properties defined in the instance.

Parameters

offset?: Size

Optional offset from the original position.

resolution?: Size

Optional screen resolution to adapt the position and size.

Returns

void

Implementation of

IDrawable.draw

Defined in

client/ui/Text.ts:85

draw(caption, pos, scale, color, font, alignment, dropShadow, outline, wordWrap, resolution)

draw(caption, pos, scale, color?, font?, alignment?, dropShadow?, outline?, wordWrap?, resolution?): void

Draws the text with overridden parameters.

Parameters

caption: string

The text to display.

pos: Point

The position of the text.

scale: number

The scale of the text.

color?: Color

The color of the text.

font?: Font

The font of the text.

alignment?: Alignment

The alignment of the text.

dropShadow?: boolean

Whether to apply a drop shadow.

outline?: boolean

Whether to apply an outline.

wordWrap?: Size

The word wrap size.

resolution?: Size

The screen resolution.

Returns

void

Implementation of

IDrawable.draw

Defined in

client/ui/Text.ts:100


addLongString()

static addLongString(str): void

Adds a long string to the text component, splitting it into chunks that can be rendered in GTA V.

Parameters

str: string

The string to add.

Returns

void

Defined in

client/ui/Text.ts:177


draw()

static draw(caption, pos, scale, color, font, alignment, dropShadow, outline, wordWrap?, resolution?): void

Draws the text with the specified parameters.

This is a static method that can be used to draw text without needing to create an instance of Text.

Parameters

caption: string

The text to display.

pos: Point

The position of the text on the screen.

scale: number = 1

The scale of the text.

color: Color = Color.white

The color of the text.

font: Font = Font.ChaletLondon

The font of the text.

alignment: Alignment = Alignment.Left

The alignment of the text.

dropShadow: boolean = false

Whether to apply a drop shadow to the text.

outline: boolean = false

Whether to apply an outline to the text.

wordWrap?: Size

The word wrap size for the text.

resolution?: Size

The screen resolution for scaling.

Returns

void

Defined in

client/ui/Text.ts:202