Add Specially Created ttf Font to project

Hi all,

I have a special ttf font created that I need to save in a Mac/Windows desktop app. I’ve reviewed past posts, but they are a bit unclear.

I’ve added a Font folder and dragged the font over. All I get is an alias to the font. Can Xojo - without the need of an external plugin - embed ttf fonts?

Is this the correct way to install?
How do I access in code?

Apparently, when I build, I will need to install it in the Resources folder. Are they clear instructions I can read?

All help appreciated,
John…

Here is an example project: GitHub: jo-tools/customappfonts

This example Xojo project shows how one can embed custom App Fonts in Xojo-built applications.
The fonts are not being installed on the OS - they are only available while the application is running. This may be necessary, depending on the license of your fonts.

In the ReadMe, see the “How to”…

macOS

  • needs an Info.plist, where you define the ATSApplicationFontsPath
    (pre Xojo 2015, you add that to the project items; starting with Xojo 2025r1 you can edit the Property List in the IDE)
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>ATSApplicationFontsPath</key>
      <string>AppFonts/</string>
    </dict>
    </plist>
    
  • use a Copy-File Build Step to copy the Font File in the Resources Folder, with the above Info.plist into a subfolder in there, e.g. AppFonts

Windows

  • again a Copy-File Build Step to add the Font
  • needs Declares to active the font within the application (see example project)
2 Likes

Hi Jurg,

Thank you!

I’ll study and imitate.

I’ll see how far I get.

Appreciate,
John…