Difference between revisions of "FontBase:getAdvanceX"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2011.6<br/> === Description === <br /> Returns the width of the first `size` characters of `text`. <br /> Note that this value is not...")
 
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
 
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 +
'''Class:''' [[FontBase]]<br/>
 +
 
=== Description ===
 
=== Description ===
<br />
+
Returns the width of the first ''size'' characters of ''text''.
Returns the width of the first `size` characters of `text`. <br />
+
<syntaxhighlight lang="lua">
Note that this value is not equal to the 3rd return value (width) of `getBounds()`. <br />
+
(number) = FontBase:getAdvanceX(text,letterSpacing,size)
`getBounds()` returns a rectangle describing the bounds this string will cover <br />
+
</syntaxhighlight>
whereas `getAdvanceX()` returns the distance to where the next string should be drawn.<br />
+
 
<br />
+
Note that this value is not equal to the 3rd return value (width) of ''getBounds()''.
<source lang="lua">
+
 
(number), = FontBase:getAdvanceX(textletterSpacingsize,)
+
''getBounds()'' returns a rectangle describing the bounds this string will cover whereas ''getAdvanceX()'' returns the distance to where the next string should be drawn.
</source>
+
 
'''text:''' (string) ''''''<br/>
+
=== Parameters ===
'''letterSpacing:''' (number, default = 0) ''''''<br/>
+
'''text''': (string) <br/>
'''size:''' (number, optional) ''''''<br/>
+
'''letterSpacing''': (number, default = 0) <br/>
'''Returns''' (number) The width of the first size characters of text.<br/>
+
'''size''': (number, optional) <br/>
 +
 
 +
=== Return values ===
 +
'''Returns''' (number) the width of the first size characters of text<br/>
 +
 
 +
{{FontBase}}

Latest revision as of 18:12, 17 November 2023

Available since: Gideros 2011.6
Class: FontBase

Description

Returns the width of the first size characters of text.

(number) = FontBase:getAdvanceX(text,letterSpacing,size)

Note that this value is not equal to the 3rd return value (width) of getBounds().

getBounds() returns a rectangle describing the bounds this string will cover whereas getAdvanceX() returns the distance to where the next string should be drawn.

Parameters

text: (string)
letterSpacing: (number, default = 0)
size: (number, optional)

Return values

Returns (number) the width of the first size characters of text