I'm doing some text rendering in Cocoa using NSAttributedString, and setting the font and underline properties and all that jazz. However, I can't figure out how I can change the text's tracking. Any suggestions?
A:
My solution so far has simply been to use the kerning attribute, as tracking and kerning are similar. Is there any better solution?
Josh Matthews
2008-11-14 18:56:03
A:
I don't think font tracking is an exposed property for text layout with attributed strings.
You could perhaps use the available expansion attribute on whitespace, and manually insert whitespace characters with scaling factors to influence their width, but I expect that would be a fiddly hack for anything other than trivial cases.
The only other route I can think of is to use your own custom attributes along with an NSLayoutManager
subclass. The cocoa text system is extremely flexible, but with that flexibility comes a greater degree of complexity.
cms
2008-11-15 13:55:14