MBS Plugin - FolderItem.FontActivateMBS()

  1. 7 months ago

    Yves P

    17 Jan 2019 Pre-Release Testers Europe, Germany, Konstanz
    Edited 7 months ago

    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?

  2. Christian S

    17 Jan 2019 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    I am sorry, but I have no real help here.
    We use CTFontManagerRegisterFontsForURLs for Mac internally and that doesn't return which fonts are in the file.

    You could only use CoreText plugin classes to query the fonts and their URLs to see if your file is already there or after activation there.

    See CTFontMBS .URL and CoreTextMBS .RegisterFontsForFile

  3. Yves P

    17 Jan 2019 Pre-Release Testers Europe, Germany, Konstanz
    Edited 7 months ago

    Thank you. :-)

    I will look if CoreTextMBS helps me here.

    Unfortunately I will need a solution for windows. FolderItem.FontActivateMBS() works on Windows too thanks to MBS.

    But:

    • Can someone confirm that XOJO caches the fonts when calling Font(index) and FontCount?
    • Will that be the case on Windows too?

    If FontCount and Font(index) never get updated, I need to look after another solution on Windows for collecting fonts.

  4. Christian S

    17 Jan 2019 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    Font/FontCount in Xojo may only check fonts on start of application.

    Check WindowsFontFamilyMBS class for Windows.

or Sign Up to reply!