Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Text.FromStyles
Creates styled text from JSON made with Text.Style.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Text | 11.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "Text.FromStyles"; json ) More
Parameters
Parameter | Description | Example |
---|---|---|
json | A JSON text or reference. |
Result
Returns styled text or error.
Description
Creates styled text from JSON made with Text.Style.Great function to construct styled text via JSON functions.
Input is a JSON array with objects.
Each object with a "text" item is considered and others ignored.
If there is a "hasSize" entry with false, we ignore size. Otherwise we read "size" value and use it.
If there is a "hasFont" entry with false, we ignore font details. Otherwise we lookup "font" entry and use it as font name. If that is missing, we look for "fontID" entry with a font ID. For FileMaker before version 14, we look also for "fontScript" entry.
If there is a "hasColor" entry with false, we ignore color details. Otherwise we look for "red", "green" and "blue". If one exists, we use them for color. If an "alpha" entry exists, we add the alpha value. Alternatively we use "colorHex" for a hex color value.
If there is a "hasFace" entry with false, we ignore face style. Otherwise we lookup "face" with a numeric value for the style. We then also look for boolean entries named bold, italic, underline, outline, shadow, condense, extend, strikethrough, smallCaps, superscript, subscript, wordUnderline, doubleUnderline entries to adjust style.
Sample | JSON |
Some blue text with hex color | [{"colorHex":"0044FE","alpha":255,"text":"blue"}] |
Same blue text with red, green and blue. | [{"red":0,"green":68,"blue":254,"alpha":255,"text":"blue"}] |
Text in bold | [{"text":"Hello", "bold":true}] |
Text in 24pt | [{"text":"Hello", "size":24}] |
Text in Comic Sans font | [{"text":"Hello", "font":"Comic Sans MS"}] |
Hello underlined and World strike through | [{"text":"Hello", "underlined": true}, {"text": " "}, {"text":"World", "strikethrough": true}] |
The attribute named shadow is in current FileMaker used to highlight text in yellow.
Examples
Create styled text with JSON:
MBS( "Text.FromStyles"; "[{\"text\":\"Hello\", \"underlined\": true}, {\"text\": \" \"}, {\"text\":\"World\", \"strikethrough\": true}]")
See also
Release notes
- Version 11.3
- Added Text.FromStyles function.
Example Databases
Blog Entries
- New in MBS FileMaker Plugin 11.3
- Neues MBS FileMaker Plugin 11.3
- MBS FileMaker Plugin 11.3 - More than 6500 Functions In One Plugin
- MBS FileMaker Plugin, version 11.3pr1
This function checks for a license.
Created 19th May 2021, last changed 24th April 2023