Name
TextExtent -- retrieve detailed information about a text extent (V2.5)
Synopsis
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 4.7 there is an optional argument that can be used to specify the character encoding inside string$. This defaults to whatever character encoding has been set as the text library default encoding using SetDefaultEncoding(). See SetDefaultEncoding for details.

Inputs
string$
source text
encoding
optional: character encoding used by string$ (defaults to the text library encoding specified in the last call to SetDefaultEncoding()) (V4.7)
Results
extent
detailed information about the text's dimensions

Show TOC