DgsSetFont: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (DGS OOP Syntax changing)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
This function sets the font of a dgs element to be used when drawing text.
This function sets the font of a dgs element to be used when drawing text. '''a dgs font can be affected by [[dgsSetSystemFont]]'''


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dgsSetFont( element dgsElement, mixed font )
bool dgsSetFont( element dgsElement, mixed font )
</syntaxhighlight>  
</syntaxhighlight>
{{DGS/OOP|
    Method = DGSElement:setFont|
    Variable = font|
    Counterpart = dgsGetFont
}}


===Required Arguments===
===Required Arguments===
*'''dgsElement:''' The DGS element you wish to change the font of
*'''dgsElement:''' The DGS element you wish to change the font of
*'''font:''' Either a custom dx font element or the name of a built-in dx font (Can be affected by [[setSystemFont]]).
*'''font:''' Either a custom dx font element or the name of a built-in dx font (see here [[Standard_DGS_Font_Names]])
 
===Returns===
===Returns===
Returns ''true'' if the font has been successfully set on the dgs element, ''false'' otherwise.
Returns ''true'' if the font has been successfully set on the dgs element, ''false'' otherwise.
Line 25: Line 31:
</syntaxhighlight>
</syntaxhighlight>


==See Also==
=See Also=
{{DGSFUNCTIONS}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Functions</span>==
{{DGS General Functions}}
 
==<span style="color:#eb3f00;text-shadow:0.05em 0.05em 0.2em #00000099;">General Events</span>==
{{DGS Events/General}}

Latest revision as of 21:19, 3 May 2021

This function sets the font of a dgs element to be used when drawing text. a dgs font can be affected by dgsSetSystemFont

Syntax

bool dgsSetFont( element dgsElement, mixed font )

DGS OOP Syntax Help! I don't understand this!

Method: DGSElement:setFont(...)
Variable: .font
Counterpart: dgsGetFont

Required Arguments

  • dgsElement: The DGS element you wish to change the font of
  • font: Either a custom dx font element or the name of a built-in dx font (see here Standard_DGS_Font_Names)

Returns

Returns true if the font has been successfully set on the dgs element, false otherwise.

Example

This example sets and gets the font of a pre-made gui element and outputs it to chat box.

DGS = exports.dgs
-- We create a dummy gui label to get text of
local dummyGUIElement = DGS:dgsCreateLabel ( 0.45, 0.48, 0.10, 0.04, "Hello world", true )
DGS:dgsSetFont ( dummyGUIElement, "clear" )
-- Output the font of the label to chat box
outputChatBox ( "Font used in the DGS label: " .. DGS:dgsGetFont ( dummyGuiElement ) )

See Also

General Functions

General Events