• 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 text with NSLayoutManager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing text with NSLayoutManager


  • Subject: Re: Drawing text with NSLayoutManager
  • From: Brian Webster <email@hidden>
  • Date: Sat, 28 Jun 2003 11:28:42 -0500

Well, the reason that your glyphs are being drawn like that is because the point that you pass into drawGlyphsForGlyphRange:atPoint: is the point at which the first glyph in the layout manager is to be located, not the first glyph in the range that you've specified. So in your example, you would need to move the point to the left by the width of the previous glyph each time you draw the next glyph to have them aligned vertically.

If you really do want to draw glyphs one at a time, using CoreGraphics may well speed up your display. I don't know exactly what the speed implications of using NSLayoutManager in this way are, but I could certainly imagine there being a speed hit, especially for large amounts of text.

On Friday, June 27, 2003, at 12:41 PM, email@hidden wrote:

Message: 1
Date: Fri, 27 Jun 2003 01:32:08 -0400
Subject: Drawing text with NSLayoutManager
From: Eric Wang <email@hidden>
To: <email@hidden>

I'm currently using NSLayoutManager's -drawGlyphsForGlyphRange:atPoint:
method to draw text in a custom view. I want to draw the text in a column
like the following:

a
b
c

However, when I call -drawGlyphs... to draw each line, NSLayoutManager seems
to advance the horizontal drawing position so that I end up with something
like this:

a
b
c

Adding hard line breaks to the NSLayoutManager's text storage causes the
text to line up vertically, but I don't want to do this for a couple of
reasons:

One, I don't wish to the change underlying model of my application for the
purposes of presenting a view on the data.

Two, the vertical space between each line varies. I'm calculating the
position at which to draw the line each time I call -drawGlyphs... and
passing it as part of the ...atPoint: parameter. Adding hard line breaks
messes up this calculation by causing the lines to be spaced further apart
than they should be.

I also attempted to subclass NSTypeSetter, but the documentation is scarce
on that and I wasn't able to get it working. It seems like a bit of a kludge
for something that should be relatively simple.

I'm thinking that perhaps I should be working at a lower level with the
Quartz (CGContextShowGlyphsAtPoint() looks promising) and/or ATSUI text
drawing APIs.

Any thoughts on this are appreciated.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.

  • Follow-Ups:
    • Re: Drawing text with NSLayoutManager
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: iTunes & AppleScript
  • Next by Date: Ejecting a volume in seperate thread
  • Previous by thread: Drawing text with NSLayoutManager
  • Next by thread: Re: Drawing text with NSLayoutManager
  • Index(es):
    • Date
    • Thread