• 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: Drawing lines between text [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing lines between text [SOLVED]


  • Subject: Re: Drawing lines between text [SOLVED]
  • From: Keith Blount <email@hidden>
  • Date: Sat, 9 Jul 2005 15:44:29 -0700 (PDT)

Nevermind, it seems that Tiger's new attributed string
method, -boundingRectWithSize:, works nicely:

float lineHeight = [textAstr
boundingRectWithSize:NSMakeSize(1e7,100)
options:nil].size.height;

Thanks anyway,
Keith

--Original Message--

Hello,

I feel this should be very simple, so I am probably
overlooking something very obvious, but...

I am drawing an attributed string in a view using
NSAttributedString's drawInRect: method. I would like
to make this view look like lined paper, so I need to
draw lines between each line of text. How can I get
the line height for each line of text drawn to
calculate this?

I have tried calling pointSize on the font, but this
doesn't give the padding. I have also tried using
NSLayoutManager like this:

NSLayoutManager *lm = [[NSLayoutManager alloc] init];
float lineHeight = [lm defaultLineHeightForFont:font];
[lm release];

Neither seem to work right for all fonts, however.

If anyone has any suggestions of how to calculate the
line height for arbitrary fonts when using
NSAttributedString's drawInRect: so that I can figure
out where to draw my lines, I would be very grateful.

Many thanks,
Keith

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Documentation frustrations
  • Next by Date: Re: "untitled" vs "Untitled"
  • Previous by thread: Drawing lines between text
  • Next by thread: Newby Question
  • Index(es):
    • Date
    • Thread