font.render: Difference between revisions
PerikiyoXD (talk | contribs) No edit summary |
m (fixed the script example's spacing) |
||
(One intermediate revision by the same user not shown) | |||
Line 11: | Line 11: | ||
|parameter5 = float justify The justify alignment of the text, as a float. | |parameter5 = float justify The justify alignment of the text, as a float. | ||
|parameter6 = float size The size of the text, as a float. | |parameter6 = float size The size of the text, as a float. | ||
|parameter7 = bool wordWrap optional false Whether word wrap is enabled. | |parameter7 = int colour The colour of the text, as an integer; visit the [[Defines/IV#GTA_IV_-_Colour_Defines|colour defines]] page for info. | ||
| | |parameter8 = bool wordWrap optional false Whether word wrap is enabled. | ||
| | |parameter9 = bool colourCodes optional true Whether colour codes are resolved. | ||
| | |parameter10 = bool ignoreColourCodes optional false Whether colour codes are not resolved. | ||
|parameter11 = bool shadow optional false Whether to draw a shadow for the text. | |||
|usage = draw text on the screen using a font | |usage = draw text on the screen using a font | ||
|return1 = void | |return1 = void | ||
|returnFail1 = void | |returnFail1 = void | ||
|notes = You can use different colours using [[Format_Tags]] | |notes = You can use different colours using [[Format_Tags]] | ||
|exampleJSCS = 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); | |||
} | |||
} | |||
}); | |||
}} | }} |
Latest revision as of 15:21, 3 October 2021
Method
Client Only
Online and Offline
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 ])
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
- You can use different colours using Format_Tags.
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