I have a question about the very useful function FolderItem.FontActivateMBS(), maybe someone knows a solution.
How can I find out which font I can use in a canvas after activating a font file. For example, the file martel-v2-latin-200.ttf contains the font named “Martel UltraLight”. How can I get this name?
The Xojo internal font management does not contain an activated font, because Xojo somehow caches the fonts at startup or the first call and does not update this.
On Mac, the NSFontManagerMBS contains the change after a few seconds, so I’m currently doing this:
- Collect fonts from NSFontManagerMBS
- FolderItem.FontActivateMBS()
- Check in a timer every 0.5 seconds, if new fonts are available
- Find out the new font with a before-and-after comparison of NSFontManagerMBS
Unfortunately, this works not in all cases, because:
- with many installed fonts everything is very slow.
- FolderItem.FontActivateMBS () also returns “0 - Successful” if the font is already installed in the system. Then a change to NSFontManagerMBS will never be made. Which is why I stop the timer after 10 calls with no success.
Is there a better solution?