a2GetTextWidth()

This function returns the width of a text string rendered with Advance 2D text commands.

  Syntax
Return Integer = a2GetTextWidth(fontID, text)
  Parameters
fontID
Integer
The ID number assigned to an Advanced 2D font when it is created.
text
String
This is the text string used to calculate the width value.
  Returns

Returns the width in pixels of the text string when rendered with Advanced 2D text commands.

  Description

This function returns the width in pixels of a text string rendered with Advanced 2D text commands. The returned value includes any whitespace in the text. Note that the value is interpreted using the sizeMode and style values of the font.

  Example Code
myFont1 = a2CreateFont("ariel", 30, a2Size_Char(), a2Style_Normal())
a$ = "Some testy text."
h = a2GetLineHeight(myFont1)
w = a2GetTextWidth(myFont1,a$)
ink 0xFFFF0000,0
box 0,0,w,h
a2Text myFont1,0,0,a$,0xFFFFFFFF

WAIT KEY
  See also

a2CreateFont
a2GetLineHeight
Advanced 2D Index
Main Menu