Difference between revisions of "FontBase:getAdvanceX"

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