Difference between revisions of "FontBase:layoutText"

From GiderosMobile
(----)
Line 1: Line 1:
__NOTOC__
+
'''Available since:''' Gideros 2017.10<br/>
<languages />
+
'''Class:''' [[FontBase]]<br/>
'''<translate>Available since</translate>:''' Gideros 2017.10<br/>
+
 
'''<translate>Class</translate>:''' [[Special:MyLanguage/FontBase|FontBase]]<br/>
+
=== Description ===
=== <translate>Description</translate> ===
+
Compute the layout of the given text according to a given rectangular region size, layout flags and other parameters.
<translate><br />
+
 
Compute the layout of the given text according to a given rectangular region size, layout flags and other parameters.<br />
+
Refer to [[TextField:setLayout]] for a description of the arguments.
<br />
+
 
Refer to [[Special:MyLanguage/TextField:setLayout|TextField:setLayout]] for a description of the arguments.<br/>
 
 
The returned table contains the following fields:
 
The returned table contains the following fields:
- x,y,w,h: Computed bounding box of the full text
+
* x,y,w,h: Computed bounding box of the full text
- lines: The number of lines used to display the text
+
* lines: The number of lines used to display the text
- parts: Information about individual chunks of texts.
+
* parts: Information about individual chunks of texts
<br /><br />
+
 
Each table in the part field of the returned table describe the placement of chunks of text. Their fields are:
+
 
- text: The text to display in this chunk
+
Each table in the part field of the returned table describes the placement of chunks of text. Their fields are:
- x,y,w,h: Computed bounding box of this chunk   
+
* text: The text to display in this chunk
- dx,dy: Coordinates to draw this chunk at
+
* x,y,w,h: Computed bounding box of this chunk   
- sep: separator character that came just after this chunk in text block
+
* dx,dy: Coordinates to draw this chunk at
- line: line number this chunk belongs to</translate>
+
* sep: separator character that came just after this chunk in text block
 +
* line: line number this chunk belongs to
 +
 
 +
 
 
<source lang="lua">
 
<source lang="lua">
 
(table) = FontBase:layoutText(text,width,height,flags,letterSpacing,lineSpacing,tabSpace,breakChar)
 
(table) = FontBase:layoutText(text,width,height,flags,letterSpacing,lineSpacing,tabSpace,breakChar)
 
</source>
 
</source>
=== <translate>Parameters</translate> ===
+
 
'''text''': (string) <translate></translate> <br/>
+
=== Parameters ===
'''width''': (number) <translate></translate> <br/>
+
'''text''': (string) <br/>
'''height''': (number) <translate></translate> <br/>
+
'''width''': (number) <br/>
'''flags''': (number, default=FontBase.TLF_NOWRAP) <translate></translate> <br/>
+
'''height''': (number) <br/>
'''letterSpacing''': (number, default = 0) <translate></translate> <br/>
+
'''flags''': (number, default=FontBase.TLF_NOWRAP) <br/>
'''lineSpacing''': (number, default = 0) <translate></translate> <br/>
+
'''letterSpacing''': (number, default = 0) <br/>
'''tabSpace''': (number, default = 4) <translate></translate> <br/>
+
'''lineSpacing''': (number, default = 0) <br/>
'''breakChar''': (string) <translate></translate> '''optional'''<br/>
+
'''tabSpace''': (number, default = 4) <br/>
=== <translate>Return values</translate> ===
+
'''breakChar''': (string) '''optional''' <br/>
'''<translate>Returns</translate>''' (table) <translate>A table describing how to draw the given text.</translate><br/>
+
 
 +
=== Return values ===
 +
'''Returns''' (table) A table describing how to draw the given text. <br/>
 +
 
 +
----
 +
{{Special:PrefixIndex/FontBase:}}
 +
<br/>
 +
 
 +
{{Special:PrefixIndex/FontBase.TLF}}
 +
<br/>

Revision as of 21:31, 2 December 2019

Available since: Gideros 2017.10
Class: FontBase

Description

Compute the layout of the given text according to a given rectangular region size, layout flags and other parameters.

Refer to TextField:setLayout for a description of the arguments.

The returned table contains the following fields:

  • x,y,w,h: Computed bounding box of the full text
  • lines: The number of lines used to display the text
  • parts: Information about individual chunks of texts


Each table in the part field of the returned table describes the placement of chunks of text. Their fields are:

  • text: The text to display in this chunk
  • x,y,w,h: Computed bounding box of this chunk
  • dx,dy: Coordinates to draw this chunk at
  • sep: separator character that came just after this chunk in text block
  • line: line number this chunk belongs to


(table) = FontBase:layoutText(text,width,height,flags,letterSpacing,lineSpacing,tabSpace,breakChar)

Parameters

text: (string)
width: (number)
height: (number)
flags: (number, default=FontBase.TLF_NOWRAP)
letterSpacing: (number, default = 0)
lineSpacing: (number, default = 0)
tabSpace: (number, default = 4)
breakChar: (string) optional

Return values

Returns (table) A table describing how to draw the given text.