Since iOS 13, apps can make use of a new Fonts entitlement, with a sub option 'Use Installed Fonts' to use custom fonts installed by special font provider apps. These apps make use of the same entitlement, but with sub option 'Install Fonts'. Examples of such apps are CreativeCloud from Adobe and MyFonts from MonoType.
Using installed fonts works fine, except with WKWebView.
As an example, I use the following code to load some text in a WKWebView control, and use a UIFontPickerViewController to select a font. After selecting the font, both the font of the webView control and navigation bar are being updated. This works fine with built-in system fonts. But after selecting a custom installed font, only the font of the navigation bar is being updated. This indicates that the app supports the installed custom font, but not the WKWebView control.
Question: what must I do get those custom installed fonts working in WKWebView?
An older technique of installing custom fonts in iOS made use of configuration profiles. This works perfectly with WKWebView, but my question is about the new iOS 13 font installation technique, as explained here: https://developer.apple.com/videos/play/wwdc2019/227/
Using installed fonts works fine, except with WKWebView.
As an example, I use the following code to load some text in a WKWebView control, and use a UIFontPickerViewController to select a font. After selecting the font, both the font of the webView control and navigation bar are being updated. This works fine with built-in system fonts. But after selecting a custom installed font, only the font of the navigation bar is being updated. This indicates that the app supports the installed custom font, but not the WKWebView control.
Code Block class ViewController: UIViewController { @IBOutlet weak var webView: WKWebView! var font = "Avenir Next" let html = """ <style> body { font-family: 'FONTFAMILY'; font-size: 40pt; } </style> <body> This is a test string to demonstrate the characters of a custom installed font named “<b>FONTFAMILY</b>”. Hopefully it will not be replaced by Times New Roman or some other ugly looking font. </body> """ override func viewDidLoad() { super.viewDidLoad() loadHTML() } @IBAction func selectFont(_ sender: AnyObject) { let picker = UIFontPickerViewController() picker.delegate = self present(picker, animated: true, completion: nil) } fileprivate func loadHTML() { webView.loadHTMLString(html.replacingOccurrences(of: "FONTFAMILY", with: font), baseURL: nil) navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.font : UIFont(name: font, size: 24)!] } } extension ViewController: UIFontPickerViewControllerDelegate { func fontPickerViewControllerDidPickFont(_ viewController: UIFontPickerViewController) { if let family = viewController.selectedFontDescriptor?.object(forKey: .family) as? String { font = family loadHTML() } } }
Question: what must I do get those custom installed fonts working in WKWebView?
An older technique of installing custom fonts in iOS made use of configuration profiles. This works perfectly with WKWebView, but my question is about the new iOS 13 font installation technique, as explained here: https://developer.apple.com/videos/play/wwdc2019/227/