font.render

Revision as of 15:21, 3 October 2021 by EricPlayZ (talk | contribs) (fixed the script example's spacing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Method Client Only icon-iii.png icon-vc.png icon-sa.png icon-iv.png Online and Offline

Available since Client 1.0.0

void font.render(string text, Vec2 position, float width, float align, float justify, float size, int colour, [ bool wordWrap = false, bool colourCodes = true, bool ignoreColourCodes = false, bool shadow = false ])

The font.render method is used to draw text on the screen using a font.

Parameters

1) string text The text to draw.
2) Vec2 position The 2D position for the text.
3) float width The maximum width of the text, in pixels.
4) float align The horizontal alignment of the text, as a float.
5) float justify The justify alignment of the text, as a float.
6) float size The size of the text, as a float.
7) int colour The colour of the text, as an integer; visit the colour defines page for info.
8) bool wordWrap Optional, defaults to false. Whether word wrap is enabled.
9) bool colourCodes Optional, defaults to true. Whether colour codes are resolved.
10) bool ignoreColourCodes Optional, defaults to false. Whether colour codes are not resolved.
11) bool shadow Optional, defaults to false. Whether to draw a shadow for the text.

Return

void This method doesn't return a value.

Types

Client Font

Notes

Examples

Example 1 - JavaScript - Client-Side:

let gameMsgFont = null; let gameMsgText = "Welcome to the server."; let gameMsgColour = COLOUR_YELLOW; let gameMsgDuration = 7500; let gameMsgStart = 0;

bindEventHandler("OnResourceReady", thisResource, (event, resource) => {

   let fontStream = openFile("pricedown.ttf");
   if (fontStream != null) {
       gameMsgFont = lucasFont.createFont(fontStream, 28.0);
       fontStream.close();
   }

});

bindEventHandler("OnResourceStart", thisResource, (event, resource) => {

   gameMsgStart = sdl.ticks;

});

addEventHandler("OnDrawnHUD", (event) => { if (gta.ivGamemode != 8) return;

if (sdl.ticks - gameMsgStart < gameMsgDuration ) { if (gameMsgFont != null) { gameMsgFont.render(gameMsgText, [0, gta.height - 45], gta.width, 0.5, 0.0, gameMsgFont.size, gameMsgColour, true, true, false, true); } } });

Compatibility

There isn't any compatibility information for this method.

Related

Client Related

        font.measure
        font.render
        font.size