Using fonts in app without installing them?

Is there a way to specify loading the font from the main running folder? Don’t necessarily want to install a bunch of fonts to a user’s desktop (this is for a Steam app). :slight_smile:

Would SpecialFolder.CurrentWorkingDirectory work?

Would you be so kind to first test using Desktop and see if it works ? After that you can put the file anywhere you like.

Next to the exe is GetFolderItem("").

Put them in the lib folder with a copyStep command (after build)
I use a font folder inside and then to load the fonts I use

#if TargetWin32 dim f as FolderItem=app.ExecutableFile.Parent.Child(app.ExecutableFile.Name.Replace(".exe"," Libs")) if f.Exists then f=f.Child("fonts") if f.Exists then for i as Integer=1 to f.Count fonts.Append f.Item(i) next end if end if for i as integer=0 to Fonts.Ubound TemporarilyInstallFont(fonts(i)) next #endif
fonts is an array that I use then for the UninstallTemporaryFont call
The copy step is simple:
create one after build, set applies to Both, subdirectory font, destination framework folder (that’s the Lib folder for win build)

Here’s an example Xojo project that shows how to use custom app fonts in Windows, macOS and Linux applications: CustomAppFonts

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. On Windows and Linux it’s even possible to load/unload during runtime

Notes

  1. macOS: Fonts are being added using Info.plist (see the corresponding project item) and a Post-Build CopyFiles-Step
  2. Windows/Linux: Fonts are being added using Declares in modCustomAppFonts (see the corresponding Module in the project) and a Post-Build CopyFiles-Step

Note that this app, like others built with MBS ActivateFontMBS, does not work under Windows in anything > 2016R3, because apparently Direct2D does not support dynamic font activation.

This thread is old now. There have been other threads about the same topic where that particular issue was discussed. So far no workaround has been found AFAIK.

Right but at least now I know how to add them (for now) on Linux

Indeed :slight_smile:

Right. The first Direct2D Xojo Versions in 2017 have broken this.
Works again in 2018+ Xojo Versions.