BTW, I've just documented this limitation in Radar:
rdar://5795937 AppKit string tightening should work with non-truncating line break modes

This one is up to you—if you think it would be a useful addition, great; if not, I guess you can punt it as "Behaves Correctly" or something.


John Stiles wrote:
Right, we went over this a month or two ago. But in this case, I actually needed finer-grained control over the tightening—for instance, I didn't want an ellipsis when the tightening threshold is exceeded. Instead, when the tightening threshold is exceeded, I just want it to use the maximum tightening value and clip the excess. However, NSLineBreakByClipping does not work with AppKit tightening, and there is no way to make NSLineBreakByTruncatingTail stop displaying an ellipsis.

So in short, I needed to implement my own custom tightening with the NSKern attribute. Works like a charm, it's just way more code :)

I didn't even know NSKern existed until now, but it works great.


Aki Inoue wrote:
John,

The tightening is controlled by -[NSParagraphStyle tighteningFactorForTruncation].

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSParagraphStyle_Class/Reference/Reference.html#//apple_ref/occ/instm/NSParagraphStyle/tighteningFactorForTruncation

Aki

On 2008/03/12, at 11:35, John Stiles wrote:
Followup: this requires a bit of math but it works great in practice. I have a lot more control over the tightening now, which is just what I needed. Thanks!

John Stiles wrote:
Interesting! I didn't think to use kerning directly. Thank you for the idea!! It makes sense since obviously I am trying to do something a little more sophisticated than the default "tighten" functionality.

How does "line tightening" pick an appropriate kerning value? I'm thinking you could use -cellSize to get the actual string width, and then you could figure out the ratio of cell frame to desired size to compute a kerning value... but I've never used kerning before so I could be off in the weeds here.


glenn andreas wrote:

On Mar 11, 2008, at 9:54 PM, John Stiles wrote:

Gah, I spoke too soon.
This "solution" actually disables tightening entirely. So I'm back to square one. Please help!


You could try to manually squeeze the result by setting an attributed string's NSKernAttributeName value, but that would be far from automatic (since you'd have to be constantly measuring the string, redoing the kerning, and, in all likelihood, handle the auto-ellipsification yourself).

It could probably be handled by a transformer in a binding, so it may not be too bad, though there's no obvious way for the binding to know the line width it needs to try to shrink the string to...


Glenn Andreas                      [EMAIL PROTECTED]
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next generation of fractal art



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jstiles%40blizzard.com

This email sent to [EMAIL PROTECTED]
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/aki%40apple.com

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/jstiles%40blizzard.com

This email sent to [EMAIL PROTECTED]
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to