DTCoreText – Cocoanetics https://www.cocoanetics.com Our DNA is written in Swift Fri, 30 Sep 2022 20:04:48 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.3 39982308 DTCoreText 1.6.27 https://www.cocoanetics.com/2022/09/dtcoretext-1-6-27/ https://www.cocoanetics.com/2022/09/dtcoretext-1-6-27/#comments Fri, 30 Sep 2022 20:04:47 +0000 https://www.cocoanetics.com/?p=10738 This is a maintenance release, after the previous one was more than a year old. There were a couple open pull requests which I merged.

Changes

  • Changed DTTextAttachment to be a subclass of NSTextAttachment to avoid some crashes.
  • Remove the checking of tiled layer in DTAttributedTextContentView.
  • Removed unneeded constant causing a warning
  • Added support for underline color
  • Added ability to pass in a UIFontDescriptor for DTHTMLAttributedStringBuilder

On the first change I think there might be some further work necessary to actually use the native sizing functions correctly. DTCoreText was started at a time when there was no NSTextAttachment on iOS (before iOS 7). Since we cannot even build for this platform any more for a few years, it was ok to make this change.

The last change got implemented to deal with an issue where Times New Roman would be used instead of San Francisco UI.

Many thanks to the contributors of pull requests!

]]>
https://www.cocoanetics.com/2022/09/dtcoretext-1-6-27/feed/ 10 10738
DTCoreText 1.6.26 https://www.cocoanetics.com/2021/06/dtcoretext-1-6-26/ https://www.cocoanetics.com/2021/06/dtcoretext-1-6-26/#comments Wed, 30 Jun 2021 08:29:04 +0000 https://www.cocoanetics.com/?p=10702 This is a maintenance release mostly fixing build issues.

Changes

  • FIXED: Some weak support issues
  • FIXED: Some warnings
  • FIXED: Enabled bitcode
  • FIXED: Missing weak for DTAccessibilityElement and view proxy
  • FIXED: [Demo] About VC didn’t set correct content inset
  • FIXED: Select correct fallbackFont with matching traits when multiple are available
  • FIXED: Check for default font
  • NEW: [Demo] Demonstrate dark/light mode adjustment on About Box

Thanks to Marcin Ugarenko for his generous contributions.

The update has been tagged on GitHub, pushed to Cocoapods trunk and is also available via SPM.

]]>
https://www.cocoanetics.com/2021/06/dtcoretext-1-6-26/feed/ 23 10702
DTCoreText 1.6.23 https://www.cocoanetics.com/2019/09/dtcoretext-1-6-23/ https://www.cocoanetics.com/2019/09/dtcoretext-1-6-23/#comments Wed, 11 Sep 2019 07:07:41 +0000 https://www.cocoanetics.com/?p=10613 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.

]]>
https://www.cocoanetics.com/2019/09/dtcoretext-1-6-23/feed/ 1 10613
DTCoreText 1.6.22 https://www.cocoanetics.com/2019/06/dtcoretext-1-6-22/ https://www.cocoanetics.com/2019/06/dtcoretext-1-6-22/#comments Fri, 28 Jun 2019 13:24:50 +0000 https://www.cocoanetics.com/?p=10604 The previous release was almost 2 years ago, and several people requested this one, so I finally got around to doing it.

This is mostly a maintenance release, my reasons for not maintaining this project I did outline in the post accompanying the previous release. Here are the commits contributing to this release.

The biggest change came from Duncan Cunningham who removed support for static library and instead moved the default.css into the framework resources. DTCoreText uses this style sheet for formatting default values. In order to support static libraries is had to be compiled into embedded binary code. This proved problematic in newer Xcode versions.

Other fixes addressed some edge cases like illegal spaces in URLs, fixing a crash when using images in LI elements, fixing a ton of Xcode warnings and some small build fixes for tvOS.

I am thanking those who stubbornly stick with DTCoreText and keep contributing to it. The new release is available on Cocoapods and has been tagged on GitHub.

]]>
https://www.cocoanetics.com/2019/06/dtcoretext-1-6-22/feed/ 18 10604
DTCoreText 1.6.20 https://www.cocoanetics.com/2017/02/dtcoretext-1-6-20/ https://www.cocoanetics.com/2017/02/dtcoretext-1-6-20/#comments Thu, 23 Feb 2017 18:51:10 +0000 https://www.cocoanetics.com/?p=10433 Since the previous maintenance release was 4 months ago, I decided to make a new release with the contributions made since then. DTCoreText is not being actively developed further by me because by this time the HTML-parsing capabilities built into iOS 9 and 10 are sufficient for most peoples needs. But since I keep getting good pull requests (with unit tests a welcome extra) I keep releasing these every couple of months.

Changes

  • FIXED: Crash when img tag had an invalid file URL to an animated GIF
  • FIXED: Superfluos import for framework-based umbrella header causing build issues
  • FIXED: Link will be nil when cleanString contains Chinese characters
  • FIXED: DTCoreTextLayoutFrame memory leak
  • FIXED: Certain truncations might cause a crash
  • FIXED: Skip unpaired bracket } & fix NSUInteger underflow in CSS parser
  • FIXED: Space to “apple converted space span” conversion for 2 spaces
  • FIXED: Text range for text block (for drawing background rectangle) might be computed incorrectly
  • FIXED: Crash with IFRAME src attribute had less than 2 characters
  • ADDED: Look for `DTCoreTextFontOverrides.plist` in the main bundle if its not found in the local bundle
  • ADDED: Expanded character decoding support in stringByReplacingHTMLEntities

Thank you to Kasper Weibel, David X. Lau and several contributors who have not set a proper name on Github, making it impossible for me to thank them by name.

At the time of this writing I have 80 open issues, but for the reason stated above I am going to close all of them for lack of activity. I’ve seen this practise in action on the Fastlane project. I will personally only ever work on an issue if somebody hires me to do so. Other issues will only be addressed if somebody provides a pull request.

For that reason, issues that basically say “I am a beginner and I cannot get the project to compile” are rather useless. Sorry, but I don’t have time to give free support or mentoring.

I’d rather be working on starting a new project that adds some missing functionality that Apple still hasn’t added to HTML parsing in iOS, specifically support for editing bulleted and numbered lists. In particular I am interested in adding proper handling for lists to UITextView which I am using in this Babyforum.at app which we recently built for a client. I did it once before in DTRichTextEditor, we should be able to do that in a UITextView subclass as well.

But enough ranting, for those people who still insist on using DTCoreText, the update is tagged on GitHub and available via Cocoapods. I don’t know about Carthage, sorry. But I think somebody mentioned that this works as well.

]]>
https://www.cocoanetics.com/2017/02/dtcoretext-1-6-20/feed/ 1 10433
DTCoreText 1.6.19 https://www.cocoanetics.com/2016/10/dtcoretext-1-6-19/ https://www.cocoanetics.com/2016/10/dtcoretext-1-6-19/#comments Tue, 11 Oct 2016 17:21:08 +0000 https://www.cocoanetics.com/?p=10322 Hot on the heels of the previous release for DTCoreText this update hot-fixes several issues which were introduced in the previous release.

Changes

  • FIXED: Incompatibility with iOS 7, using containsString
  • FIXED: Memory Leak in DTLazyImageView, using NSURLSession
  • FIXED: [Demo] When loading remote images the relayout needs to be done on next runloop
  • FIXED: Incorrect tabulator used for list items
  • FIXED: In default.css P tags had a -webkit-margin-before (which gets parsed since 1.6.18) causing superfluous extra space before paragraphs

I decided to push this release without delay so that everybody needing DTCoreText can get fixes for bugs I introduced in 1.6.18 mostly fixing Xcode 8 warnings. Tips are welcome to PayPal oliver@cocoanetics.com.

The update is tagged on GitHub and available via CocoaPods.

]]>
https://www.cocoanetics.com/2016/10/dtcoretext-1-6-19/feed/ 1 10322
DTCoreText 1.6.18 https://www.cocoanetics.com/2016/09/dtcoretext-1-6-18/ https://www.cocoanetics.com/2016/09/dtcoretext-1-6-18/#comments Fri, 30 Sep 2016 14:29:41 +0000 https://www.cocoanetics.com/?p=10318 Since the prior release of DTCoreText, 9 months ago, a few issues became apparent with Xcode 8. Some people contributed cool stuff like support for use in app extensions as well as tvOS support.

Changes

  • ADDED: tvOS Support
  • ADDED: Property to better support display remote images with DTAttributedTextCell
  • ADDED: Extension sub spec (which removes some things that cannot be used in Extensions)
  • ADDED: Parse margin-top as paragraphSpacingBefore
  • ADDED: Support for list style with roman numerals
  • ADDED: 10% performance increase parsing CSS styles that only have a single part
  • ADDED: Usage of custom font name via CSS in programming guide
  • FIXED: Potential crash on iOS 10 from more strict CoreText functions
  • FIXED: Crash when list-style-image was not a string
  • FIXED: Crash when comparing lines and one of them was nil
  • FIXED: Several Xcode 8 build warnings
  • FIXED: All deprecation warnings related to CoreText text alignment constants
  • FIXED: NSURLConnection deprecation by using NSURLSessionDataTask instead
  • FIXED: Deprecation warnings related to percentEncoding, replaced with HTML entity encoding
  • FIXED: Several Carthage build problems

Thank you for your contributions, Philipp Schmid, David X. Lau, James Hurst, Brandon Tram, Alex WU, Kai Maschke,  Ryan Maxwell, Ian Ynda-Hummel, Florian Friedrich. (I can only thank people who have a proper name set up on GitHub)

One particular annoyance resulted from a bug in CocoaPods where the prepare_command of the podspec is not being executed. I am using this to generate a C file from the default CSS file and if it is not run, the linting of the spec fails. So as an immediate workaround I added a copy of this file to the repo.

The most work I needed to do on DTLazyImageView which required replacing the prior NSURLConnection logic with NSURLSessionDataTask while preserving the progressive download capability.

The update is tagged on GitHub (for Carthage) and available on Cocoapods.

]]>
https://www.cocoanetics.com/2016/09/dtcoretext-1-6-18/feed/ 1 10318
DTCoreText 1.6.17 https://www.cocoanetics.com/2015/12/dtcoretext-1-6-17/ https://www.cocoanetics.com/2015/12/dtcoretext-1-6-17/#respond Tue, 29 Dec 2015 09:06:31 +0000 https://www.cocoanetics.com/?p=10020 This update to DTCoreText aggregates and release half a year worth of fixes. The previous update was in July 2015.

Changes

  • ADDED: Line truncation
  • ADDED: Minimum and maximum line heights
  • ADDED: Ability to change paragraph tag name
  • ADDED: Support for use in app extension
  • FIXED: Build error for integrating via sub-project
  • FIXED: CTLineUtils compiler warnings
  • FIXED: Setup Guide for sub-project integration
  • FIXED: Missing paragraph style for text attachments
  • CHANGED: Updated to DTFoundation 1.6.9

Thanks Aleksandr Deundiak, Jin, Niklas Saers, Ryan Gregg, Philipp Schmid, David X. Lau and Michał Zaborowski for their contributions towards this release.

The update is tagged on GitHub as well as available via Cocoapods.

]]>
https://www.cocoanetics.com/2015/12/dtcoretext-1-6-17/feed/ 0 10020
DTCoreText 1.6.16 https://www.cocoanetics.com/2015/07/dtcoretext-1-6-16/ https://www.cocoanetics.com/2015/07/dtcoretext-1-6-16/#comments Sat, 04 Jul 2015 09:58:02 +0000 https://www.cocoanetics.com/?p=9761 This is a big update for DTCoreText, maybe even deserving of a minor version bump. It aggregates fixes and enhancements contributed over more than 4 months. This kind of proves that DTCoreText is alive and getting better all the time.

Changes

  • FIXED: Compatibility with CocoaPods 0.36 and frameworks
  • FIXED: Missing super calls in -awakeFromNib
  • FIXED: Dependency problems with DTWeakSupport.h
  • FIXED: Problem with “Cursive” tag and a Custom Font Cursive
  • FIXED: CGFloat values were used as bool values within if statements
  • FIXED: Additional CGFloat build issue on xCode 7
  • FIXED: Wrong foreground color attribute used for appending NL
  • FIXED: Xcode warning for unused expression result
  • FIXED: CGFloat build issue on xCode 7
  • ADDED: Honour the value of NSBaselineOffsetAttributeName
  • ADDED: DTCoreText.framework for iOS
  • ADDED: Improve AutoLayout in DTAttributedTextContentView
  • ADDED: DTDocumentPreserveTrailingSpaces boolean option

The main driver for this release was the fact that people where experiencing problems using DTCoreText in Swift apps. The main reason for these issues resulted from some unclear cross dependencies dependencies and imports that would throw the module building. Support for modules/frameworks arrived in CocoaPods 0.36 and I hadn’t gotten around to fixing this until now.

When debugging the module support I also clarified the imports in many source files. Instead of blankly always importing the CoreText.h umbrella header I switched to importing exactly the needed files. I added a dynamic iOS framework for this purpose which would show me where module building problems would reside.

The main contributes to this release were. Thank you guys!

To be honored as a contributor you need to have contributed code to the project. You can do so by sending pull requests with improvements. Please always send them against the develop branch.

The update is available on CocoaPods as well as tagged on GitHub.

]]>
https://www.cocoanetics.com/2015/07/dtcoretext-1-6-16/feed/ 1 9761
DTCoreText 1.6.15 https://www.cocoanetics.com/2015/02/dtcoretext-1-6-15/ https://www.cocoanetics.com/2015/02/dtcoretext-1-6-15/#comments Thu, 19 Feb 2015 14:11:35 +0000 http://www.cocoanetics.com/?p=9465 This maintenance update for DTCoreText aggregates several contributed fixes.

Changes

  • FIXED: NULL dereference when CTLineCreateTruncatedLine fails
  • FIXED: UIColor would be set as CTForegroundColor in some cases, causing problems
  • FIXED: Possible exception ‘Auto Layout still required after executing -layoutSubviews.’
  • CHANGED: Use defaultParagraphStyle rather than assert crash for DTUseiOS6Attributes option
  • CHANGED: DTFoundation updated to 1.7.5 (few minor fixes for DTHTMLParser)

The primary contributions for this release came from Jeremy Foo, Silvan Dähn, Ryan McLeod and Matt Andersen.

The update is available via Cocoapods and tagged on GitHub.

]]>
https://www.cocoanetics.com/2015/02/dtcoretext-1-6-15/feed/ 1 9465
DTCoreText 1.6.14 https://www.cocoanetics.com/2014/10/dtcoretext-1-6-14/ https://www.cocoanetics.com/2014/10/dtcoretext-1-6-14/#respond Fri, 17 Oct 2014 18:55:05 +0000 http://www.cocoanetics.com/?p=9350 This maintenance release for DTCoreText addresses one pressing issue with images represented in data URLs and a collection of a few contributions.

Changes

  • FIXED: Parsing @2x Image in data URL causes it to double in size
  • FIXED: In Demo app, image elements seem to block scrolling in iOS 8
  • FIXED: Missing Helvetica Neue Italic font in iOS 7.0.x would cause crash
  • FIXED: Potential memory leak in -newMatchingFont
  • FIXED: Potential crash from iOS bug, calling -accessibilityElementAtIndex: with non-existing index
  • ADDED: Override -coretext-fontname to use direct “PostScript” names for fonts

I was particularly astonished that the image growing issue in data URLs was not spotted any sooner. The problem there was that the persisted NSData from an image would contain all the pixels, but lose the information about the scale factor. This caused the pixel size to end up being used, as opposed to the point size.

The scrolling problem resulted from UIScrollView causing a viewDidLayoutSubviews as well in the view it is contained in, beginning with iOS 8. The demo is long overdue to be switched to storyboard, and so there is is currently a workaround in place that adjusts the contentOffset and various insets based on the layout guides. This is done exactly in the mentioned method. This would cause the contentOffset to be reset to the top whenever something in the scroll view triggered a layout.

This release benefitted from contributes by Jean-Charles BERTINSteve Pint and Jan Thiele. Thank you!

The updated is tagged on GitHub and also available via Cocoapods trunk. If you are using DTRichTextEditor via pods you also get this automatically if you pod update.

]]>
https://www.cocoanetics.com/2014/10/dtcoretext-1-6-14/feed/ 0 9350
DTCoreText 1.6.13 https://www.cocoanetics.com/2014/07/dtcoretext-1-6-13/ https://www.cocoanetics.com/2014/07/dtcoretext-1-6-13/#comments Fri, 04 Jul 2014 11:54:18 +0000 http://www.cocoanetics.com/?p=9215 This hot fix release for DTCoreText contains a pressing crashing bug related to changed behavior in iOS 8. It also adds support for animated GIFs. Plus a few other annoyances.

Changes

  • FIXED: Traditional margin-* style value following -webkit-margin-* reset margin values to 0
  • FIXED: iOS 8 crash resulting from Apple making CTRunGetPositionsPtr lazy
  • FIXED: HTML element with text attachment and display:none would emit extra object placeholder
  • FIXED: Child element with display:none would not be ignored when determining if parent needs to be output
  • FIXED: Animated GIF only showing first frame
  • FIXED: DTHTMLWriter does not output attachments
  • CHANGED: Migrated unit testing to XCTest
  • CHANGED: DTFoundation updated to 1.7.1 (for animated GIF support)

Note that the animated GIF support is only recommended for small size animated GIFs since it is using a method that keeps it compatible with UIImageView. Interestingly a UIImageView apparently automatically animates an image that has multiple frames. I only did an implementation for iOS because there we know for a fact that ImageIO does not properly deal with animated GIFs. Thanks to Kerem Erkan for contributing the iOS 8 fix.

On the maintenance side, Xcode 6 kept complaining that I was using a deprecated unit testing framework. So I finally migrated to XCTest since the Xcode version installed on Travis-CI build nodes is sufficiently recent to handle that.

The update is tagged as release on GitHub and also posted to CocoaPods.

]]>
https://www.cocoanetics.com/2014/07/dtcoretext-1-6-13/feed/ 2 9215
DTCoreText 1.6.12 https://www.cocoanetics.com/2014/06/dtcoretext-1-6-12/ https://www.cocoanetics.com/2014/06/dtcoretext-1-6-12/#respond Wed, 04 Jun 2014 14:34:48 +0000 http://www.cocoanetics.com/?p=9156 It’s been a while since the previous update to DTCoreText. Now that I mostly finished my book I pulled together a new maintenance release.

Changes

  • FIXED: Crash parsing background shorthand containing color
  • FIXED: Broken unit test for uncompressing background shorthand
  • FIXED: DTAttributeLabel doesn’t use delegate methods to render text from truncationString param
  • FIXED: Links parsed from HTML are not recognized in UITextView (using NS-style attributes)
  • FIXED: Memory leak in -CGColor method on MacOSX target.
  • FIXED: lineHeightMultiple not being transferred to NSParagraphStyle
  • FIXED: Warnings related to disparities between properties and ivars
  • FIXED: Build issues because submodule did not include 32-bit slice
  • FIXED: Crash on iOS 5 due to unguarded selector calling
  • FIXED: Warning about deprecated methods using deployment target >= iOS 7
  • ADDED: Ability to specify default font face name
  • CHANGED: Updated DTFoundation to 1.7.0

Note about bugs occurring on iOS 8 BETA: Please file bug reports with Apple for issues you find while using DTCoreText. There is almost nothing we can do in DTCoreText if methods from Core Text are buggy. Very rarely we can try to find a workaround, but while iOS 8 is in flux it is of major importance that Apple is made aware of new bugs.

To clarify one thing that some people get confused about. If you want to use an attributed string coming out of DTCoreText parsing HTML with UITextView you have to use the DTUseiOS6Attributes parsing option. Without this the classic Core Text kCT* attributes are used. With it, modern NS* attributes will be used. Those are sometimes incompatible and provide less features than their older counterparts, which is why the “old style” attributes will remain the default for the near future.

Thanks go to Jean-Charles Bertin, Adam SchlagLuca Bartoletti and Marcin Krzyzanowski for their contributions to this release.

The update is tagged on GitHub and also available via CocoaPods.

]]>
https://www.cocoanetics.com/2014/06/dtcoretext-1-6-12/feed/ 0 9156
DTCoreText 1.6.11 https://www.cocoanetics.com/2014/03/dtcoretext-1-6-11/ https://www.cocoanetics.com/2014/03/dtcoretext-1-6-11/#respond Tue, 18 Mar 2014 13:12:24 +0000 http://www.cocoanetics.com/?p=9052 In the 3 months since the previous release quite a few things happened on the development branch of DTCoreText. Additionally there were some issues related to iOS 7.1 and Xcode 5.1 that needed urgent addressing. Even though there are a few new features I decided to go with a bug fix version number. This way if somebody is using DTCoreText via CocoaPods and has the the version restricted to 1.6.x he gets all the critical fixes.

Changes

  • FIXED: Crash on 64-bit CPU if an element had no foreground color
  • FIXED: CGColor sanity check randomly fails
  • FIXED: Implicit conversion warnings in DTHTMLWriter
  • FIXED: Analyzer warnings in DTHTMLWriter
  • FIXED: Compatibility of NSColor for deployment targets prior to OS X 10.8
  • FIXED: Various documentation fixes
  • CHANGED: Manual drawing of underlines removed as of iOS 7
  • CHANGED: Completeness of AppleDoc comments now part of unit tests
  • ADDED: Options parameter to setting HTML string convenience method on DTAttributedTextCell
  • ADDED: Support for CSS “background” shorthand
  • ADDED: Screenshot button to Demo app
  • ADDED: NSCoding support for DTTextAttachment, DTTextBlock and DTCSSListStyle

Major contributors to this release were Ryan Johnson, Wim Haanstra and Jean-Charles Bertin.

I had to revert one addition where glyph runs would use the current drawing context foreground color for filling. Unfortunately CoreText bug I reported long time ago is still acting up, the attributes dictionary of a glyph run returns an invalid CGColor reference which causes a crash drawing a glyph run later on. As a workaround we need to have all elements have a default color.

The update is tagged on the GitHub repo and also available via CocoaPods.

]]>
https://www.cocoanetics.com/2014/03/dtcoretext-1-6-11/feed/ 0 9052
DTCoreText 1.6.10 https://www.cocoanetics.com/2013/12/dtcoretext-1-6-10/ https://www.cocoanetics.com/2013/12/dtcoretext-1-6-10/#comments Wed, 18 Dec 2013 12:59:38 +0000 http://www.cocoanetics.com/?p=8890 This maintenance release of DTCoreText fixes some minor issues. I’m releasing it in preparation for a maintenance release of DTRichTextEditor.

Changes

  • FIXED: 64-bit macros for creating an NSNumber from CGFloat
  • FIXED: Path in podspec `prepare_command` breaks if `CDPATH` defined in shell
  • ADDED: Support for border-color, -radius, -width for use with TTAttributedLabel
  • CHANGED: Updated DTFoundation to 1.6.1
  • DOCS: Added explanation for lazy image loading to programming guide

The macro thing was a problem when building for 64-bit iOS simulator. The podspec thing affected people having a CDPATH set in their shell environment variables. I merged in the pull request by Martin Guillon who uses the HTML parsing facilities of DTCoreText together with TTAttributedLabel. Those attributes are ignored when drawing the attributed strings with the provide UI classes.

The release is tagged on GitHub as well as available via CocoaPods.

]]>
https://www.cocoanetics.com/2013/12/dtcoretext-1-6-10/feed/ 2 8890
DTCoreText 1.6.9 https://www.cocoanetics.com/2013/11/dtcoretext-1-6-9/ https://www.cocoanetics.com/2013/11/dtcoretext-1-6-9/#comments Fri, 15 Nov 2013 14:48:36 +0000 http://www.cocoanetics.com/?p=8840 This new version improves DTCoreText on many fronts. I wanted to get this out because quite a few improvements had amassed since 1.6.8.

Changes

  • FIXED: Repackage headers needed from DTFoundation to static universal and Mac frameworks
  • FIXED: Duplicate symbol when using DTCoreText together with DTTransition pod
  • FIXED: Compiler warnings
  • FIXED: iOS 6-style attributes would not work on iOS 6 simulator
  • FIXED: Renamed instances of “class” to avoid conflict with C++ reserved word
  • FIXED: Method to set fallback font family would allow setting of invalid font family name
  • FIXED: Crash in DTAttributedTextContentView related to text box range finding
  • ADDED: BundleLoaderDummy to allow unit-testing code dealing UIFont
  • ADDED: arm64 support
  • ADDED: ability to determine attributed string size with unknown width
  • CHANGED: Updated DTFoundation requirement to 1.6.0

Several fixes were supplied by the community. In particular there was a situation where the NSFoundation version would differ for iOS 6 on simulator and device. This disabled iOS6-style text attributes on simulator.

For situations where there is an invalid font family encountered when parsing HTML, the font fallback family would be used. However this allowed setting an invalid family name. Trying to do that now causes an exception to tell you that you are doing something wrong.

For supporting arm64 many many loss-of-precision warnings needed to be fixed. Turns out the best method for doing that is to include a specific math library that comes with the system but does not seem to be enabled by default: tgmath.h.

Several problems were addressed by updating DTFoundation where used C-functions are now all prefixed to avoid conflicts with other libraries or pods.

Note: There is a known issue with CATiledLayer losing tiles. See my Radar here. There is quite a few people discussing this on the Apple developer forum. If having to wait for Apple to fix this is a major problem for you then you should replace it with a custom tiling implementation. My DTStripedLayer might be a good interim solution, though it is not production-tested. This can be found in the DTFoundation project in an Experimental subfolder. If somebody is willing to give this a good testing I can promote it to production status.

Note: The CGFLOAT_OPEN_HEIGHT constant has been renamed to CGFLOAT_HEIGHT_UNKNOWN.

The update is tagged on GitHub and also available via CocoaPods.

]]>
https://www.cocoanetics.com/2013/11/dtcoretext-1-6-9/feed/ 7 8840
DTCoreText 1.6.8 https://www.cocoanetics.com/2013/10/dtcoretext-1-6-8/ https://www.cocoanetics.com/2013/10/dtcoretext-1-6-8/#comments Fri, 04 Oct 2013 17:27:33 +0000 http://www.cocoanetics.com/?p=8734 This update for DTCoreText is our most error-free release ever! We added tons of new unit tests and added code coverage monitoring via Coveralls. And in doing so we found a plethora of little bugs creeping around in little untested (“uncovered”) code.

Changes

  • ADDED: VIDEO tag with no direct SRC attribute will now use the first one from its child-tags
  • ADDED: support for letter-spacing CSS style (mapped to kerning)
  • ADDED: Proper nested lists support in DTHTMLWriter
  • ADDED: Code coverage support
  • FIXED: Resizing behavior of DTLazyImageView
  • FIXED: Potential dead-lock in [DTAttributedTextContentView layoutFrame]
  • FIXED: HTML with lists might trigger a crash because an NSArray was mutated while being enumerated
  • FIXED: Output of nested lists was broken
  • FIXED: Elusive crash related to text blocks
  • FIXED: a situation where some whitespace does not get trimmed correctly
  • FIXED: CSS inheritance would clash mit direct inheritance of DTHTMLElements
  • FIXED: The “not-found range” {NSNotFound,0} was used incorrectly in several spots
  • CHANGED: Replaced instances of using DTVersion for runtime version checking with method recommended by Apple
  • CHANGED: Requires DTFoundation 1.5.4

Adding code coverage report generation aided greatly in finding some places where the code was misbehaving. I also found that code coverage analysis has sort of a “gamification effect”. You get motivated to try to spot some places that – if you write a proper unit test for them – can get your score a bit higher.

DTCoreText Code Coverage

 

Adding unit tests for fixed bugs – where possible – plus this extra motivation from the Coveralls chart increased the number of unit tests from about 110 to 160.

I was also able to get in a few very old feature requests that turned out to be relatively straightforward. For example adding support for the letter-spacing CSS attribute:

letter-spacing support

The update is tagged on GitHub and also available via CocoaPods.

Shout Out: doRadiology Apps

This edition’s shout out goes to several radiology apps by BestApps. For example Diagnostic Radiology – Dynamic Approach to Abdominal Radiology.

Radiology using DTCoreText doRadiology uses DTCoreText

According to the app’s maker “This app uses DTCoreText for everything”. This app got recently nominated Semi-Finalist by Radiology Website Aunt Minnie for the Best Radiology Mobile App 2013 award.

Congratulations to doRadiology! Great to hear that DTCoreText has enabled production of such high caliber apps.

]]>
https://www.cocoanetics.com/2013/10/dtcoretext-1-6-8/feed/ 10 8734
DTCoreText 1.6.7 https://www.cocoanetics.com/2013/09/dtcoretext-1-6-7/ https://www.cocoanetics.com/2013/09/dtcoretext-1-6-7/#comments Fri, 20 Sep 2013 17:07:36 +0000 http://www.cocoanetics.com/?p=8673 Following the public availability of iOS 7 and having collected a good amount of fixes, I felt that it is a good time to release the next maintenance update to DTCoreText.

Changes

  • FIXED: Paragraphs within list items render incorrectly
  • FIXED: Reformatting URLs embedded in iframe for YouTube
  • FIXED: Performance degradation when using padding in iOS 7
  • FIXED: Crash when using iOS6 Attributes and Drawing Underline on iOS 7
  • FIXED: Crash on iOS6 caused by DTAttributedTextCell iOS 7 workaround
  • FIXED: Indenting for DTAttributedTextCell when used in grouped tableview
  • FIXED: DTHTMLWriter does not output inline styles for UL/OL
  • FIXED: DTHTMLWriter outputs empty span tag following LI
  • FIXED: background-color is not transferred from UL style to LI
  • ADDED: Option to skip font setup for use-cases not requiring CSS parsing
  • ADDED: Tab stop support in modern attributes’ NSParagraphStyle
  • CHANGED: Moved hex methods for color into DTColorFunctions

iOS 7 finally adds public API for tab stops in NSParagraphStyle. So I implemented the bridging of these from and to DTCoreTextParagraphStyle. This fixes the list indentation and makes it possible to use DTCoreText for one more use case on iOS 7. This functionality is only available if you build with iOS 7 SDK and the app is executing on iOS 7. Elsewhere this functionality is dormant, or if you are building with iOS 6 SDK #defined out.

In particular I would like to point out a difference in how iOS 7 seems to handle custom attributes backed by an array. Apparently iOS 7 compares such arrays now and this got stumped by DTTextBlock missing an efficient isEqual: method. This was tricky to discover, but Konstantin Boukreev rose to the challenge. I also added an isEqual: to list styles and improved it for font descriptors for good measure.

The update is tagged on the master branch on GitHab as well as available via CocoaPods.

]]>
https://www.cocoanetics.com/2013/09/dtcoretext-1-6-7/feed/ 6 8673
DTCoreText 1.6.6 + DTRichTextEditor 1.6.3 https://www.cocoanetics.com/2013/08/dtcoretext-1-6-6/ https://www.cocoanetics.com/2013/08/dtcoretext-1-6-6/#comments Fri, 30 Aug 2013 14:20:55 +0000 http://www.cocoanetics.com/?p=8600 Again, another maintenance release for DTCoreText and DTRichTextEditorwhich mostly addresses issues introduced by the recent CSS handling rewrite. It also further enhances support for CSS style cascading.

DTCoreText 1.6.6

  • FIXED: Out of Memory crash on certain HTML documents extensively using CSS cascading
  • FIXED: CSS Cascading by element name performance problem
  • FIXED: Issue with font-size doubling in some situations due to CSS selector being applied
  • FIXED: Last line in a list might lose the tab stops
  • FIXED: glyph run has wrong stringRange for hyphenated lines
  • FIXED: all failing unit tests
  • ADDED: Single Selector Cascading
  • ADDED: Many unit tests for CSS Cascading
  • ADDED: Travis-CI for automated testing of pull requests
  • CHANGED: CSS selector matching now evaluates specificity

DTRichTextEditor 1.6.3

  • FIXED: Pasting from Google Drive might yield empty content
  • CHANGED: Updated DTCoreText to 1.6.6

This release’s MVP is again Amro Mousa who fixed and enhanced all that was related to CSS Cascading. Amro rewrote the matching engine and this improved parsing performance several orders of magnitude. Specifically the specificity is a very complex topic but apparently Amro has mastered that as well.

I would also like to highlight the tab stop issue. This was a great catch by Thomas Torp. This caused a funny issue for some people building for platforms which allow zeroing-weak-references. I am using DT_WEAK_VARIABLE to denote variables as weak where the deployment target permits that (>= iOS 5). Strangely there seemed to be a situation where a weak CFArrayRef would become nil and thus the array would be assigned as nil.

weak issue

On the left you see the corrected code, on the right the original. Honestly I don’t quite understand why it would do that. If you have an answer to this riddle please let me know in the comments.

The new version is tagged on GitHub as well as available via CocoaPods.

]]>
https://www.cocoanetics.com/2013/08/dtcoretext-1-6-6/feed/ 6 8600
DTCoreText 1.6.5 https://www.cocoanetics.com/2013/08/dtcoretext-1-6-5/ https://www.cocoanetics.com/2013/08/dtcoretext-1-6-5/#comments Thu, 22 Aug 2013 15:19:16 +0000 http://www.cocoanetics.com/?p=8587 This is a maintenance release addressing several crashing problems.

 Changes

  • FIXED: Crash encountering empty text block
  • FIXED: Crash encountering ARGB color in CSS
  • ADDED: More general support for CSS cascading
  • ADDED: Programming Guide
  • ADDED: Documentation for enums

There where some issues necessary that were still a knock on effect of changing the CSS attribute parsing in 1.6.3 to also return arrays for things like a comma-separated list of font families. This also caused the ARGB issue since there were also commas. While fixing this – again – Amro Mousa made the CSS cascading even more general.

Here’s a comparison of cascaded CSS attributes between Safari and DTCoreText.

Safari versus DTCoreText

24df2be0-0687-11e3-8203-948a984e68df

Awesome work, Amro! Those look darn near identical to me. (see the pull request for the HTML behind this)

I needed to update the documentation to – finally! – include enums as AppleDoc supports them now. Since this couldn’t deal with the previous way I defined them I also changed them to be using Apple’s NS_ENUM macro to give them an underlying type.

/**
 The drawing options for DTCoreTextLayoutFrame
 */
typedef NS_ENUM(NSUInteger, DTCoreTextLayoutFrameDrawingOptions)
{
	/**
	 The default method for drawing draws links and attachments. Links are drawn non-highlighted
	 */
	DTCoreTextLayoutFrameDrawingDefault              = 1<<0,
 
	/**
	 Links are not drawn, e.g. if they are displayed via custom buttons
	 */
	DTCoreTextLayoutFrameDrawingOmitLinks            = 1<<1,
 
	/**
	 Text attachments are omitted from drawing, e.g. if they are displayed via custom views
	 */
	DTCoreTextLayoutFrameDrawingOmitAttachments      = 1<<2,
 
	/**
	 If links are drawn they are displayed with the highlighted variant
	 */
	DTCoreTextLayoutFrameDrawingDrawLinksHighlighted = 1<<3
};

This adds a new section in the documentation for the enums as well. And while I was at it I also added a programming guide document where I plan to add common programming examples when I need to explain something. I added the smoke test example from the setup guide and also added information about pre-loading the font override table to speed up the first layout of DTCoreText considerably.

The update is tagged on GitHub as well as available via CocoaPods.

]]>
https://www.cocoanetics.com/2013/08/dtcoretext-1-6-5/feed/ 3 8587