Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Font.CalculateTextWidth
Calculates width of text.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Font | 6.5 | ✅ Yes | ✅ Yes | ❌ No | ✅ Yes, on macOS and Windows | ✅ Yes |
MBS( "Font.CalculateTextWidth"; Text { ; Font; Size } ) More
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
Text | The text to measure. | "Hello World" | |
Font | The font name. Using System font in case of empty parameter. |
"Arial" | Optional |
Size | The font size to use. Default is system font size. |
12 | Optional |
Result
Returns number or error.
Description
Calculates width of text.The plugin uses system font rendering to calculate width. This may be different from what FileMaker renders with it's own engine.
You can use the measured size to detect if text fits a field.
Mac result in logical points, but on Windows in pixels.
Examples
Calculate width of Hello World:
MBS( "Font.CalculateTextWidth"; "Hello World" )
# e.g. 70.9 on Mac and 77 on Windows.
Calculate with Arial
MBS( "Font.CalculateTextWidth"; "Hello World"; "Arial"; 12 )
# e.g. 61 on Windows, 61,7 on Mac
See also
Release notes
- Version 8.5
- Fixed bug in Font.CalculateTextWidth with loading font.
Example Databases
Blog Entries
- Calculate Text Sizes
- MBS FileMaker Plugin, version 8.5pr8
- Measure text length in FileMaker
- MBS FileMaker Plugin, version 6.5pr4
FileMaker Magazin
This function checks for a license.
Created 21st October 2016, last changed 16th November 2018
