Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus - MacOS - How to use a font that is not installed on the system

1 Posts
1 Users
0 Reactions
1,847 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

For certain projects, I'm using more and more fonts (TTF, True Type Font) for my icons instead of bitmaps. They scale better, take up less memory and work, etc.
When looking at website like IcoMoon you'll see that creating a tiny font for icons is real easy.
The only problem you'll run into is how to distribute your font with your application, without the user having to install the font.

It took me a while to figure this one out.

  • While Developing your Application

While developing an application, install the font (ttf) on your system so you can see the font while developing and testing.

  • Distributing your application and testing after uninstalling the font

To test this, I uninstall the font through FontBook (under "Applications" on your Mac) and make the following modifications (as an example);

1) In the application bundle (.app folder), you'll find the directories "Contents" -> "Resources". This is where I create a folder called "fonts".

2) After that I copy the font file (ttf) in "Contents" -> "Resources" -> "fonts".

3) in the "Contents" folder you'll have a file called "Info.plist", where you will have to add these 2 lines:

  <key>ATSApplicationFontsPath</key>
  <string>fonts</string>

Which tells your Mac that, for this applications, additional fonts can be found in 

MyApplication.app/Contents/Resources/fonts

And that's all there is to it.
When running the application, without having the font installed on your system, you Lazarus application will grab the font from there and things look better ... 


   
ReplyQuote
Share: