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 textFont of <object> to <font name>
  • PostScript Name is the PostScript name as referenced from the Font Book

7 Comments

Gabriel

i am writing an app for a project. i wanted to install custom fonts into my application but as i followed closely to this lesson , the fonts were not reflected on my application. i even tried to "answer the fontNames of this stack" but the output were the standard "(system),(default)..." i could seem to get this to work out

Elanor Buchanan

Hi Gabriel

What platform are you building your app for?

Elanor

Gabriel

i am building android. i am using livecode 9.6(dp2) and when i created a new stack just to test out the fonts, it does not work out, even though when i have copied my fonts to the stack files

Samuele

Hi, i tried to do as explained, for setting another font for mobile (android) but it didn't worked.
thanks.

Panos Merakos

Hello all,

Some particular Android fonts did not use to work because of a known bug (https://quality.livecode.com/show_bug.cgi?id=14436), but this issue was fixed in LiveCode 9.6.6 RC-1. If you are using LiveCode 9.6.6 RC-1 and above, and see still the issue, could you attach the font file you're trying to use?

Cheers,
Panos

Trevix

RE: iOS Font Mapping File
My iPhone 16.7.6 hardware sometime does not load my copy pane font Montserrat Bold. It always works on iPad and Android.
On iPhone sometime works only on second launch of the App.
I wanted to try using the Font Mapping File but:
- the command "set the font of to " on LC10 desktop does not seem to work.
- the mapping file is just a name.txt file?

Panos Merakos

Hello Trevix,

The correct command is "set the textFont of to .." - I have corrected this typo in the lesson.

The font mapping file is just a txt file, which you have to select in the iOS settings, and should contain mappings of the "common" font name with its postscript name - one per line:

=
=
..

Kind regards,
Panos
--

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.