I’m working through an Apple WWDC 2019 video about fonts, which includes this sample code for registering (enabling) fonts with the OS :
static func registerFamilies(_ names: [FontFamily], _ registrationHandler:
(([Error], Bool) -> Bool)?) {
let fontURLs = names.flatMap({ $0.urls })
CTFontManagerRegisterFontURLs(fontURLs as CFArray, .persistent, true) {
(errors: CFArray, done: Bool) -> Bool in
return processHandler(errors: errors, done: done, registrationHandler)
}
}
However, this flags several errors:
- Cannot find type “FontFamily” in scope;
- Static methods must only be declared on a type
- Cannot find processHandler in scope.
A static function affects all instances of a class, so presumably the absence of a defined class “FontFamily” is causing two errors. But it’s unclear to me what that type should be.
Presumably I have to create my own processHandler function that does… something.
I’ve imported CoreText and Foundation. What am I missing?