FolderItem.FontActivateMBS not working anymore on Windows

I have a xplatform desktop project using a custom font created by a designer, in various forms of ttf and otf. Copying it in a BuildStep into the resources folder and opening with folder item.fontActivateMBS used to work nicely.
Now, possibly after a recent Windows 10 update, it has stopped working and returns an error 1 all of the time – “parameter(system) error”. Windows 11 looks the same. Any idea for a replacement?

I haven’t had FontActivateMBS work on Windows since 2019r1.1. Very interested in temporarily activating custom fonts in more recent releases.

Is that so? Maybe it was a Xojo change, thanks for the hint! But it was definitely later than 2019 for me. Used to work until end of last year.

The old way still works here (and the declares for Mac work too, since I cannot fathom how to programmatically put a “Font” folder into Resources).

Public Sub TemporarilyInstallFont(fontFile as FolderItem, privateFont as Boolean = true)
#if TargetWindows
Soft Declare Sub AddFontResourceExW Lib “Gdi32” ( filename as WString, flags as Integer, reserved as Integer )
Soft Declare Sub AddFontResourceA Lib “Gdi32” ( filename as CString )
Soft Declare Sub AddFontResourceW Lib “Gdi32” ( filename as WString )

Const FR_PRIVATE = &h10

if privateFont and System.IsFunctionAvailable( "AddFontResourceExW", "Gdi32" ) then
  AddFontResourceExW( fontFile.ShellPath, FR_PRIVATE, 0 )
  if System.IsFunctionAvailable( "AddFontResourceW", "Gdi32" ) then
    AddFontResourceW( fontFile.ShellPath )
    AddFontResourceA( fontFile.ShellPath )
  end if
end if


#pragma unused fontFile
#pragma unused privateFont

End Sub

Thank you, Carlo! Sadly, does not work with my fonts.

I use .ttc for Mac but .ttf for windows.

I still use FontActivateMBS from the current MBS plugins and it works for me
(for at least the majority of my customers, or I would have heard about it loudly by now).
But I compile for Windows using Xojo 2015
Its important to deactivate it on exit, is that relevant?

And FontActivateMBS does just call AddFontResourceExW.

You can read about it here:

Thanks all. I finally checked the font in Windows font viewer and found that it does not consider it a legitimate ttf font anymore. It did so in the past. So yes, it were Windows changes and no, nothing wrong with FontActivate from my point of view. Work for the designer!

1 Like

by my tests, .ttc fonts work all right when installed,
but when they are temporarely loaded, then listboxes and graphics (for instance in a canvas) revert to a system font, at least in Xojo apps.
While all other objects (textareas, checkboxes, labels etc. etc.) are OK.
But they i.e. listbox and graphics show the right temporarely loaded .ttf font.

I found something very weird with this font. The designer sent it again as ttf in a zip file, and when I unpack it with Windows on a disk of my Windows VM and check it with Font Viewer, it will be ok.

If I unpack it onto the Mac file system, no matter if I use the Mac itself or the VM and its shared folders, Font Preview will show an error stating this is not a valid font. The same file, viewed with macOS preview, will show a font preview. When I move the “working” font to the Mac file system, it will cease to be recognised.

Any idea what could be wrong? We are reverting to ImageSets now, but the reason bothers me. What could be causing the different treatment of the same file, depending on its location?

Michel Bujardet is the expert here,

… but I have experienced TTF fonts that Windows is happy with, but Mac complains about.
It only needs a few glyphs missing and it can claim the font may be corrupt.

A custom font I had commissioned works one way on Windows, yet delivers the glyphs in a completely different ‘order’ on the Mac. They are fussy beasts.

Check in terminal for extended attributes:


I guess the downloaded ZIP archive has a attribute which is passed on the included files while unzipping.
Remove the attribute via


and unzip the archive again. Can you now use the font?

1 Like

Yes, and I would understand much of that. I have been living in the prepress world for longer than my career as a software developer exists.
But why does it make a difference to Windows where the file rests? There shouldn’t be any differences. I never experienced something like that since the early days of PostScript.

@TomE Brilliant idea, and yes, quarantine had been set. But removing it and then unzipping produces the same result: A valid font on macOS that will be blamed in Windows, except for I unpack it on the Win file system.

Good call, Jeff!

Ping @Michel_Bujardet we would love your input!

Check the macOS unzipped folder for invisible files. I guess there are files starting with “._”. Remove them and try again on Windows.
Perhaps these (for Windows) meaningless files are somehow accessed.
Otherwise you may use chksum, md5, diff etc. to compare the files unzipped on macOS vs. Windows. Perhaps this gives a clue…

There is a .DS_Store file of course but that is not copied when I duplicate the ttf to the Windows VM. And no, the same result. Good on Mac, bad on Windows. I even extracted with Keka to make sure no Mac-specific info would be added.

I’m not expert in building fonts, although I have my own fonts. Once upon a time (30 years ago) I used an app called Fontographer, or something like that.
Now I use FontForge, and for .ttf and .ttc fonts (indic fonts with more than 450 glyphs each), my settings for both Mac and Windows are as below (if it helps, but as I said I’m no expert).
Screen Shot 2022-02-04 at 8.18.34 PM

I use FontActivateMBS in one of my apps and verified it works in Windows 10 and 11.

Now, from what Ulrich shared above, I suspect the font code may not be compliant to the latest standard for Windows 10, 11, and macOS Catalina and above.

Request an updated front from the designer.


Thank you, Michel! Well, I did, at least we thought so. I also used an online font converter to try out different formats, but with the same result.

If the designer’s font would not be compatible with newest Windows requirements (could you please point me to a description of them?), wouldn’t the font unzipped on the Windows file system result in an error message too?