Ad

Our DNA is written in Swift
Jump

DTCoreText 1.6.23

Hot on the heels of the previous maintenance release, which was only 3 Months ago, this one was required because Apple no longer allows Apps to contain references to UIWebView.

The main change was that from both DTCoreText as well as, previously, DTFoundation we removed some helper methods for UIWebView. A view used by the demo to embed YouTube videos was moved to the Demo app. There was a bug in DTImageTextAttachment which caused some images to be square.

There was a missing macro which prevented compiling with a really old deployment target. That was also addressed.

There is a known issue in iOS 13 when you try to use dynamic type fonts when parsing HTML. If you try to set a dynamic type font’s name or family via parsing option, you get this warning:

CoreText performance note: Client called CTFontCreateWithName() using name ".SFUI-Regular" and got font with PostScript name "TimesNewRomanPSMT". For best performance, only use PostScript names when calling this API.

Well, the problem is that we have no API that would allow you to set the font instance itself on DTCoreText, but only to set a font or family name. This is transferred to an internal font descriptor which is handed down to sub-tags, being modified as needed. The main problem is that if you get the font descriptor for a dynamic font, there are other attributes set on the descriptor which are necessary for proper dynamic point size and font face resolution.

What’s needed here is a way to set a font itself – not just its name – as an option and to create a suitable font descriptor for it that preserves the dynamic type capability. If somebody were to sponsor the creation of this functionality, I’d be happy to add it. You can email me at oliver@cocoanetics.com to inquire. Of course, pull requests are welcome as well.

The update is tagged on GitHub and available via CocoaPods.


Tagged as:

Categories: Updates

1 Comment »