views:

269

answers:

2

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
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