Is it possible to embed a TrueType font in a stack and make it available for use in a platform independent way? Or at least in Windows and Android?
2 Answers
Adding a custom font in Android should work in the exact same way as in iOS - you simply need to reference your .ttf or .ttc font in the copy files pane of the standalone builder. They will then be automatically loaded at runtime and become available for use (they also show up in fontNames()).
On Desktop platforms, you load in custom fonts for use with the revFontLoad command. The syntax is:
revFontLoad "/path/to/my/font.fontformat"
So you would generally include the fontfile in the copy files section of the standalone builder and load it at startup.
If, for whatever reason, you wanted to actually embed the font in the stackfile, you could, theoretically, store the binary data of the fontfile as a custom property of the stack prior to building, output the custom property to a file at runtime, which you load with revFontLoad. You could even delete the file after having loaded it if the goal is to obscure the font file - note that I have tried this only in the IDE, not a standalone environment.
Also note that revFontLoad
command only works on desktop platforms, and you must have the legal right to use the font in question.

- 436
- 2
- 2
-
My experience is that revFontLoad often doesn't work, particularly on Mac OS X (this was reported as a bug but we never figured out a stable recipe). A funny thing is that OSX might show a dialog asking for permission to load the font, but not always. That's also why my customers asked me to add font installation to Installer Maker: just to make sure that the font is available. – Mark Apr 18 '13 at 22:50
On Windows, it is common practise to use an installer. E.g. InnoSetup or Installer Maker. InnoSetup is free and can be found here http://www.jrsoftware.org/isinfo.php. Installer Maker is designed for use with LiveCode and includes a special feature to install fonts on Windows. You can find it here http://www3.economy-x-talk.com/file.php?node=installer-maker.
The release notes for LC 6.0 contain the following text about embedding fonts:
Adding custom fonts In LiveCode 5.5 the ability was introduced to allow applications to bundle custom fonts which then become available to the app (and only that app) while it is running. To take advantage of this feature, all you need to do is reference the files of any fonts you wish to include in the Copy Files pane. These files can either be a direct file reference, or contained in one of the folder references. The Standalone Builder will treat any files that end with the extension ttf or ttc as font files to use in this way. Any fonts included in this way will appear in the fontNames and can be used in the same way as any other font on the system.

- 2,380
- 11
- 29
- 49