GMImage.FontTypeMetrics
-----------------------

Queries space needed for text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [GraphicsMagick](component_GraphicsMagick.md) | [7.3](newinversion73.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "GMImage.FontTypeMetrics"; ImageRef; Text ) 

**MBS**( **"GMImage.FontTypeMetrics";** /\* Queries space needed for text. \*/  
**$ImageRef**; /\* The image reference number.e.g. 1 \*/   
**$Text**) /\* Some texte.g. "Hello World" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| ImageRef | The image reference number. | 1 |
| Text | Some text | "Hello World" |

### Result

Returns list or error.

### Description

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](MathTextToNumber.md) or similar functions which always uses dot as decimal separator.  
  
See also [Font.CalculateTextWidth](FontCalculateTextWidth.md) and [DynaPDF.GetFTextHeight](DynaPDFGetFTextHeight.md) functions.  
### Examples

Draw some text on a picture:

 # open a picture   
Set Variable \[ $ref ; Value: MBS ("[GMImage.NewFromContainer](GMImageNewFromContainer.md)"; Annotate Image::InputImage ) \]   
\# set font size   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetFontPointSize](GMImageSetFontPointSize.md)"; $ref ; 20) \]   
\# set the font   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetFont](GMImageSetFont.md)"; $ref ; "@/System/Library/Fonts/LucidaGrande.ttc") \]   
\# set the fill color   
Set Variable \[ $r ; Value: MBS ("[GMImage.SetFillColor](GMImageSetFillColor.md)"; $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](GMImageAnnotate.md)"; $ref ; Annotate Image::Text ; "100x200+10+40"; 1) \]   
\# write image   
Set Field \[ Annotate Image::OutputImage ; MBS ( "[GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)"; $ref ) \]   
\# free memory   
Set Variable \[ $Error ; Value: MBS ("[GMImage.Release](GMImageRelease.md)";$ref ) \]  
Measure text:

 MBS ("GMImage.FontTypeMetrics"; $ref ; Annotate Image::Text )  
<small>  
Example result:   
"528.000000  
47.000000  
39.000000  
-8.000000  
66.000000  
40.000000"</small>### See also

- [DynaPDF.GetFTextHeight](DynaPDFGetFTextHeight.md)
- [Font.CalculateTextWidth](FontCalculateTextWidth.md)
- [GMImage.Annotate](GMImageAnnotate.md)
- [GMImage.New](GMImageNew.md)
- [GMImage.Release](GMImageRelease.md)
- [GMImage.SetFillColor](GMImageSetFillColor.md)
- [GMImage.SetFont](GMImageSetFont.md)
- [GMImage.SetFontPointSize](GMImageSetFontPointSize.md)
- [GMImage.WriteToPNGContainer](GMImageWriteToPNGContainer.md)
- [Math.TextToNumber](MathTextToNumber.md)

### Release notes

- **Version 7.3**
    - Added [GMImage.FontTypeMetrics](http://www.mbsplugins.eu/GMImageFontTypeMetrics.shtml) function.

### Example Databases

- [GraphicsMagick/Text Wrap](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/GraphicsMagick/Text%20Wrap.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 7.3pr3](https://www.mbsplugins.de/archive/2017-06-21/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 20th June 2017 , last changed 18th December 2025

  
[GMImage.FontMap](GMImageFontMap.md) - [GMImage.Format](GMImageFormat.md)

[HTML Version](GMImageFontTypeMetrics.shtml)