• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sizing text in a box
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sizing text in a box


  • Subject: Re: Sizing text in a box
  • From: "T.G. McLean" <email@hidden>
  • Date: Wed, 6 Feb 2002 08:28:52 -0700

Ben Haller wrote:

Is there really no way to find out the
extent my text will draw to before I actually draw it?

Ben --

Once again, Aaron brings up an example in his text (Chapter 15):

_____

// Display the string in the middle of a rect.
- (void) drawStringCenteredIn:(NSRect)r
{
NSPoint stringOrigin;
NSSize stringSize;

stringSize = [string sizeWithAttributes:attributes];
NSLog(@"String size: <%f,%f>", stringSize.width, stringSize.height);
stringOrigin.x = r.origin.x + (r.size.width - stringSize.width)/2;
stringOrigin.y = r.origin.y + (r.size.height - stringSize.height)/2;
[string drawAtPoint:stringOrigin withAttributes:attributes];
}

_____

The only problem with this (did you mention this just recently?) is that it tends to clip large letters. Still poking...

-- TG

------------------
T.G. McLean
email@hidden
email@hidden

"The mass of men lead lives of quiet desperation." -- Thoreau.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: " in a string (newbie)
  • Next by Date: Re: NSDocument: File attributes for backup file?
  • Previous by thread: Re: Sizing text in a box
  • Next by thread: Re: Sizing text in a box
  • Index(es):
    • Date
    • Thread