boundingRectWithSize problem?
boundingRectWithSize problem?
- Subject: boundingRectWithSize problem?
- From: Tony Pollard <email@hidden>
- Date: Wed, 25 Jan 2012 15:26:11 +0000
Hi folks,
I'm having a strange problem with NSAttributedString boundingRectWithSize in getting the needed height for a fixed width. It works 99% of the time, but it consistently underestimates the height for certain text (by approximately one line). There doesn't appear to be a pattern for the text that works and the text that fails (tested on 10.6 and 10.7).
The code is:
NSRect textRect = [attrString boundingRectWithSize:NSMakeSize(300.0, 0.0) // Width 300, any height (max height also fails)
options: NSStringDrawingUsesLineFragmentOrigin | // Needed for multi-line
NSStringDrawingDisableScreenFontSubstitution];
The attributed strings are built from data sources. Here's one that fails:
Printing description of attrString:
n. {
CdctPhraseType = Grammer;
NSColor = NSCalibratedRGBColorSpace 0.878431 0.0980392 0.160784 1;
NSFont = "LucidaGrande 9.00 pt. P [] (0x50bbd0) fobj=0x50b7b0, spc=2.85";
}A hopper is a device shaped like a large funnel, in which substances such as grain, coal, animal food, or sand can be stored.{
CdctPhraseType = Transition;
NSColor = NSCalibratedRGBColorSpace 0.227451 0.54902 0.258824 1;
NSFont = "LucidaGrande 9.00 pt. P [] (0x50bbd0) fobj=0x50b7b0, spc=2.85";
}
{
}F.ex: Large trailers came along and tipped it into a big hopper.{
CdctPhraseType = Transition;
NSColor = NSCalibratedRGBColorSpace 0.227451 0.54902 0.258824 1;
NSFont = "LucidaGrande 9.00 pt. P [] (0x50bbd0) fobj=0x50b7b0, spc=2.85";
}
The resulting Rect is too short by about 9 pixels. Anyone had the same problem?
Tony Pollard
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden