Re: NSString width

2009-09-06 Thread Dave Keck
> -[NSString boundingRectWithSize:...] might do this, especially with the > NSStringDrawingUsesDeviceMetrics flag ("Uses image glyph bounds instead of > typographic bounds"). Indeed. When I tried that method in the past, I got it working half-way with italicized text (the width was correct, but th

Re: NSString width

2009-09-06 Thread Jens Alfke
On Sep 6, 2009, at 2:03 AM, Dave Keck wrote: I've noticed this too. If you need the absolute precise pixel-size of some text, then the only way I know of (that works with all different styles of text) is manually drawing the text into some temporary context, and analyzing its pixels. -[NSStri

Re: NSString width

2009-09-06 Thread Dave Keck
> Also, keep in mind that character shapes may stick out of either edge by a > few pixels, especially with italics or script fonts. It's usually safest to > pad your bounding box by some fraction of the point-size. I've noticed this too. If you need the absolute precise pixel-size of some text, th

Re: NSString width

2009-09-05 Thread Jens Alfke
Tip: Measuring string widths is fairly expensive. (It's basically like drawing the string, minus the actual rendering of the pixels.) If you can, cache the result instead of calling it frequently. Also, keep in mind that character shapes may stick out of either edge by a few pixels, especia

Re: NSString width

2009-09-05 Thread Massimiliano Gargani
I've searched on cocoabuilder before post. I swear. Thanks a million. Max Il giorno 05/set/09, alle ore 16:32, Dave Keck ha scritto: http://lists.apple.com/archives/Cocoa-dev/2001/Nov/msg01347.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.appl

Re: NSString width

2009-09-05 Thread Dave Keck
http://lists.apple.com/archives/Cocoa-dev/2001/Nov/msg01347.html ___ 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 H

NSString width

2009-09-05 Thread Massimiliano Gargani
Hi, anybody knows how I can get the width of a string? I'm doing a "ticker like" scrolling text and it works but it always scrolls even if the string is smaller than frame width. I want the scroll starts only if the string is wider than frame. Thanks, Max __