Name
TextExtent -- retrieve detailed information about a text extent (V2.5)
Synopsis
extent = TextExtent(string$[, t])
Deprecated syntax
extent = TextExtent(string$[, encoding])
Function
This function returns detailed information about the extent of the specified string with the current font and style settings. Contrary to TextWidth() which only returns the cursor advancement TextExtent() calculates the exact bounding box for the specified string.

This function returns a table with information in the following fields:

MinX:
The offset to the left side of the rectangle. This is often negative.

MinY:
The offset from the baseline to the top of the rectangle. This is always negative.

MaxX:
The offset to the right side of the rectangle.

MaxY:
The offset from the baseline to the bottom of the rectangle.

Width:
This is the same value as returned by TextWidth().

Height:
The same value as returned by TextHeight().

The values in MinX, MinY, MaxX, and MaxY are always relative to the current cursor position. For instance, if MinX is -10, this means that Print() would start rendering this string -10 pixels from the current cursor position on the x-axis. The value in Width specifies where the cursor would end up after the rendering operation. This is often less than MaxX-1. For instance in the case of italic text, the last character will usually be much behind the final cursor position.

To calculate the full width of the specified string, simply subtract MinX from MaxX and add 1, i.e. full_width=MaxX-MinX+1.

Starting with Hollywood 10.0, this function accepts an optional table argument that allows you to specify the following additional options:

Encoding:
This tag can be used to specify the character encoding used by string$. This defaults to the character encoding set as the text library default encoding using SetDefaultEncoding(). See SetDefaultEncoding for details. (V10.0)

Charspacing:
Allows you to adjust the space between characters. You can set this to a positive or negative value. A positive value will increase the space between characters, a negative value will decrease it. (V10.0)

Inputs
string$
source text
t
optional: table argument containing further options (see above) (V10.0)
Results
extent
detailed information about the text's dimensions

Show TOC