Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.4   8.5   9.0   9.1   9.2   9.3   9.4   9.5   10.0   10.1    Statistic  


Queries space needed for text.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
GraphicsMagick 7.3 Yes Yes Yes Yes Yes
MBS( "GMImage.FontTypeMetrics"; ImageRef; text )   More


Parameter Description Example value
ImageRef The image reference number. 1
text Some text "Hello World"


Returns list or error.


Queries space needed for text.
Obtain font metrics for text string given current font, point size, and density settings.
Returns list with following values:
  • text width in pixel
  • text height in pixel
  • Ascent, the distance in pixels from the text baseline to the highest/upper grid coordinate used to place an outline point.
  • Descent, the distance in pixels from the baseline to the lowest grid coordinate used to place an outline point. Always a negative value.
  • Maximum horizontal advance in pixels.
  • Font size

To extract values, please pass through Math.TextToNumber or similar functions which always uses dot as decimal separator.


Draw some text on a picture:

# open a picture
Set Variable [ $ref ; Value: MBS("GMImage.NewFromContainer"; Annotate Image::InputImage) ]
# set font size
Set Variable [ $r ; Value: MBS("GMImage.SetFontPointsize"; $ref; 20) ]
# set the font
Set Variable [ $r ; Value: MBS("GMImage.SetFont"; $ref; "@/System/Library/Fonts/LucidaGrande.ttc") ]
# set the fill color
Set Variable [ $r ; Value: MBS("GMImage.SetFillColor"; $ref; "RGB 0 0 0") ]
# Query size for this text:
Set Variable [ $r ; Value: MBS("GMImage.FontTypeMetrics"; $ref; Annotate Image::Text) ]
# draw the text:
Set Variable [ $r ; Value: MBS("GMImage.Annotate"; $ref; Annotate Image::Text; "100x200+10+40"; 1) ]
# write image
Set Field [ Annotate Image::OutputImage ; MBS( "GMImage.WriteToPNGContainer"; $ref ) ]
# free memory
Set Variable [ $Error ; Value: MBS("GMImage.Release";$ref) ]

Measure text:

MBS("GMImage.FontTypeMetrics"; $ref; Annotate Image::Text)

Example result:

See also

Example Databases

Blog Entries

Release notes

Created 20th June 2017, last changed 21st December 2018

GMImage.FontMap   -   GMImage.Format

Feedback: Report problem or ask question.

MBS Xojo Plugins