a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Client / 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();
new Text(
caption
,pos
,scale
,color
,font
,alignment
,dropShadow
,outline
,wordWrap
?):Text
• 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
alignment:
Alignment
caption:
string
color:
Color
dropShadow:
boolean
font:
Font
outline:
boolean
pos:
Point
scale:
number
size:
Size
wordWrap:
Size
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.
• offset?: Size
Optional offset from the original position.
• resolution?: Size
Optional screen resolution to adapt the position and size.
void
draw(
caption
,pos
,scale
,color
?,font
?,alignment
?,dropShadow
?,outline
?,wordWrap
?,resolution
?):void
Draws the text with overridden 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.
void
IDrawable.draw
static
addLongString(str
):void
Adds a long string to the text component, splitting it into chunks that can be rendered in GTA V.
• str: string
The string to add.
void
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
.
• 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.
void