Using fonts in app without installing them?

  1. ‹ Older
  2. 5 years ago

    Derek D

    25 Jan 2015 Testers Newnan, GA. USA

    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). :)

  3. Derek D

    25 Jan 2015 Testers Newnan, GA. USA

    Would SpecialFolder.CurrentWorkingDirectory work?

  4. Michel B

    25 Jan 2015 Testers, Xojo Pro

    @DerekDiBenedetto 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("").

  5. Antonio R

    25 Jan 2015 Testers, Xojo Pro, Third Party Store Europe (Italy)

    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)

  6. 3 years ago

    Jürg O

    30 May 2017 Testers, Xojo Pro

    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

    -image-

  7. Michel B

    30 May 2017 Testers, Xojo Pro
    Edited 3 years ago

    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.

  8. Antonio R

    30 May 2017 Testers, Xojo Pro, Third Party Store Europe (Italy)

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

  9. Michel B

    30 May 2017 Testers, Xojo Pro

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

    Indeed :)

  10. 3 months ago

    Jürg O

    Mar 28 Testers, Xojo Pro

    @Michel B does not work under Windows in anything > 2016R3

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

or Sign Up to reply!