FROM : glenn andreas
DATE : Thu Jan 31 20:55:01 2008
On Jan 31, 2008, at 1:27 PM, John Stiles wrote:
> I've noticed that in table views, the NSTextFieldCell has the
> ability to ever-so-slightly squash its contents horizontally, to fit
> inside the table cell, before eventually giving up and truncating
> them with ellipses.
>
> Is there any way for me to programmatically do the same thing to my
> own NSTextFieldCell?
>
> As I'm typing this, suddenly I'm thinking "maybe I could fake it by
> altering the cell's bounds while leaving the frame alone"… but is
> there a better way? Changing the bounds would make the text thinner,
> which isn't quite the same as squeezing the letters more tightly
> together.
With attributed strings, you can set the paragraph style to be one
whose setLineBreakMode is one of the three truncation modes (which
provides the ellipsis), and use can even use
setTighteningFactorForTruncation to adjust how much it tries to reduce
the intercharacter spacing before switching to inserting an ellipsis.
You can probably also manually change NSKernAttributeName property of
the strings attributes as well.
Glenn Andreas <email_removed>
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next
generation of fractal art
DATE : Thu Jan 31 20:55:01 2008
On Jan 31, 2008, at 1:27 PM, John Stiles wrote:
> I've noticed that in table views, the NSTextFieldCell has the
> ability to ever-so-slightly squash its contents horizontally, to fit
> inside the table cell, before eventually giving up and truncating
> them with ellipses.
>
> Is there any way for me to programmatically do the same thing to my
> own NSTextFieldCell?
>
> As I'm typing this, suddenly I'm thinking "maybe I could fake it by
> altering the cell's bounds while leaving the frame alone"… but is
> there a better way? Changing the bounds would make the text thinner,
> which isn't quite the same as squeezing the letters more tightly
> together.
With attributed strings, you can set the paragraph style to be one
whose setLineBreakMode is one of the three truncation modes (which
provides the ellipsis), and use can even use
setTighteningFactorForTruncation to adjust how much it tries to reduce
the intercharacter spacing before switching to inserting an ellipsis.
You can probably also manually change NSKernAttributeName property of
the strings attributes as well.
Glenn Andreas <email_removed>
<http://www.gandreas.com/> wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next
generation of fractal art
| Related mails | Author | Date |
|---|---|---|
| John Stiles | Jan 31, 20:27 | |
| Peter Ammon | Jan 31, 20:53 | |
| glenn andreas | Jan 31, 20:55 | |
| John Stiles | Jan 31, 20:56 | |
| Peter Ammon | Jan 31, 21:12 | |
| John Stiles | Jan 31, 21:16 | |
| John Stiles | Jan 31, 22:37 | |
| Aki Inoue | Jan 31, 22:51 | |
| John Stiles | Jan 31, 22:54 |






Cocoa mail archive

