How to use custom fonts in your application

Sometimes the design of your app will call for a particular font that you may not be able to assume will be installed on a user's device.

You can include fonts in your standalone so they are available for use in your app without the using needing to install the font.

Include the font in the standalone

For all platforms you will need to include the font file in the Copy Files pane of the Standalone Application Settings.

Desktop Platforms

For the dekstop platforms you need to use the start using font command to load a font file from memory, making it available in your app.

on preOpenStack
   start using font file (specialFolderPath("resources") & "/Mansalva-Regular.ttf")
end preOpenStack

Assuming controls already have the custom font set as their textFont the font will be used automatically for those controls.

Mobile Platforms

On iOS and Android all you need to do is include the font the the Copy Files pane. Any controls using the custom font should display as expected.

If the font is not displaying as expected try setting the textFont of the control to the PostScript name of the font.

iOS Font Mapping File

Support for font name mapping was included in the standalone builder settings for iOS in LiveCode 6.7.5.

Updating to iOS 8.1 caused some stacks to startup extremely slowly, this was due to the fact that setting a font using a name different from its actual PostScript name was dramatically slower from iOS 8.1.

If you notice this issue you can add a custom font mapping file to your standalone.

The font mapping file has one mapping per line in the format

<font name>=<PostScript name>
<font name 2>=<PostScript name 2>
  • font name is the name used in the call set the font of <object> to <font name>
  • PostScript Name is the PostScript name as referenced from the Font Book

0 Comments

Add your comment

E-Mail me when someone replies to this comment