Search code examples
codenameone

Is it possible to replace the 'native fonts' in the simulator with a specific font?


I would like to record an 'iPhone' demo in the simulator, but the font is not the same as on the device (I know you can't distribute it). However, I found the SF Pro font for download and wanted to give it a try and was wondering if there is a simple way to override the native fonts easily (without having to change e.g. the css file)?

So that I can leave statements like this in my CSS: font-family: "native:MainRegular" but programmatically set this to be my copy of SF Pro font in the Simulator...


Solution

  • I wouldn't do this since font kerning will look "off" and if someone will notice the font he'll notice that as well. The same font will look different in Windows, Mac etc.

    But if you insist then the simplest way is to create your own skin file. This is just a simple zip file containing the skin details. E.g. this is the iPhoneX skin. Notice it doesn't include TTF files within...

    You need to add the fonts you want then use something like the google pixel skin as a reference. Look in the properties file on defining the fonts. It's pretty simple.

    As you can see from the script building the skins is literally just zipping.