Is WidgetKit capable of displaying fonts besides the system font?

Hi,

I'm attempting to display custom (but already built-into the OS) fonts in my macOS WidgetKit extension. Those are American Typewriter and Avenir.

Despite it working perfectly fine in the base app, I'm finding it impossible to get it working in the widget. I've used endless variations of things like Font.custom("Avenir", size: 25).bold(), but it just won't work.

It appears perfectly in the WidgetKit simulator, but when ran after archiving the app and putting it in my Applications folder, it won't. When the UserDefaults settings it uses are set to one of these fonts on launch, the widget will open, but it will be in some kind of Arial placeholder font.

If I change the UserDefaults key to one of these fonts while the widget is alive and reload it, it will crash completely.

This doesn't happen when displaying the System fonts, or when changing between System Default and System Serif.

Here is an example of the code I'm using to get the font (these UserDefaults values have been confirmed to be correctly synchronised):

static let getSmallFont: Font = {

        switch UserDefaults(suiteName: "com.timekeeper")?.string(forKey: "font") {

        case "modern": return Font.custom("Avenir", size: 25).bold()
        case "fancy": return .system(size: 25, weight: .bold, design: .serif)
        case "old": return Font.custom("American Typewriter", size: 25).bold()
        case nil: return .system(size: 25, weight: .bold, design: .default)
        default: return .system(size: 25, weight: .bold, design: .default)

        }

    }()

and the simple code I use to add a Text with that font to my view:

Text(entry.date, style: .time)
     .font(WidgetEntryView.getSmallFont)
Is WidgetKit capable of displaying fonts besides the system font?
 
 
Q