getTextWidth: Difference between revisions
Jump to navigation
Jump to search
Killzone Kid (talk | contribs) No edit summary |
Killzone Kid (talk | contribs) (example) |
||
Line 22: | Line 22: | ||
|x1= <code>_textWidth = "Hello World" [[getTextWidth]] ["PuristaMedium", 0.03];</code>|EXAMPLE1= | |x1= <code>_textWidth = "Hello World" [[getTextWidth]] ["PuristaMedium", 0.03];</code>|EXAMPLE1= | ||
|x2= <code>_textWidthInclMargins = ("Hello World" [[getTextWidth]] ["PuristaMedium", 0.03]) + 0.016;</code>|EXAMPLE2= | |x2= <code>_textWidthInclMargins = ("Hello World" [[getTextWidth]] ["PuristaMedium", 0.03]) + 0.016;</code>|EXAMPLE2= | ||
|x3= <code>[[private]] _ctrl = [[findDisplay]] 46 [[ctrlCreate]] ["RscText", -1]; | |||
_ctrl [[ctrlSetText]] "TestString"; | |||
_ctrl [[ctrlSetFont]] "PuristaMedium"; | |||
_ctrl [[ctrlSetFontHeight]] 0.04; | |||
[[ctrlTextWidth]] _ctrl == ("TestString" [[getTextWidth]] ["PuristaMedium", 0.04]) + 0.016; {{cc | true}}</code>|EXAMPLE3= | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ |
Revision as of 16:00, 8 October 2019
Description
- Description:
- Returns estimated width of the text based on font type and size. Similar to ctrlTextWidth but doesn't require a control and can be used to estimate text width for any control including buttons. Result does not include left and right margins (hardcoded at 0.008 each).
- Groups:
- Uncategorised
Syntax
- Syntax:
- text getTextWidth [font, size]
- Parameters:
- text: String - text string to measure
- [font, size]: Array
- font: String - font type
- size: Number - font size
- Return Value:
- Number
Examples
- Example 1:
_textWidth = "Hello World" getTextWidth ["PuristaMedium", 0.03];
- Example 2:
_textWidthInclMargins = ("Hello World" getTextWidth ["PuristaMedium", 0.03]) + 0.016;
- Example 3:
private _ctrl = findDisplay 46 ctrlCreate ["RscText", -1]; _ctrl ctrlSetText "TestString"; _ctrl ctrlSetFont "PuristaMedium"; _ctrl ctrlSetFontHeight 0.04; ctrlTextWidth _ctrl == ("TestString" getTextWidth ["PuristaMedium", 0.04]) + 0.016; // true
Additional Information
- See also:
- ctrlTextWidth
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
[[Category:Introduced with arma3dev version 1.97]][[ Category: arma3dev: New Scripting Commands | GETTEXTWIDTH]][[ Category: arma3dev: Scripting Commands | GETTEXTWIDTH]]
Notes
Bottom Section