• 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: text orientation/positioning with layout manager
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text orientation/positioning with layout manager


  • Subject: Re: text orientation/positioning with layout manager
  • From: "David F." <email@hidden>
  • Date: Mon, 31 Jan 2011 20:53:20 -0700

Douglas -- Something somewhere must be trying to compensate for the unflipped context, because the text isn't drawn upside-down.  Yes, the positioning is calculated with the assumption that the context is flipped, and effects like strikethrough and underline are drawn with the assumption that the context is flipped.

But the text glyphs themselves are always drawn right-side up.

Isn't this a bug?  (And doesn't pretty much every developer who touches the text system trip over this?)  If the glyphs were actually drawn upside-down then the problem would be pretty obvious.  Instead, forgetting to flip the context produces weird effects (but not upside-down text).  And when some one posts to the list and asks for help, and they are told that the context isn't flipped, then their first reaction is to believe that that can't be the problem--after all, the text isn't upside-down.

That was certainly my reaction the last time I tripped over this and it appears that the original poster has had that reaction as well.

So why aren't glyphs drawn upside-down when the context hasn't been flipped?!

David


On Jan 31, 2011, at 3:15 PM, Douglas Davidson wrote:

> The layout manager expects to be drawing within a flipped context.
>
> Douglas Davidson
>
> On Jan 31, 2011, at 2:09 PM, Todd Heberlein wrote:
>
>> I'm doing a simple experiment using NSTextStorage, NSLayoutManager, NSTextContainer to draw some text (I am basing this on the CircleView example because I want some of that orientation power later).
>>
>> I have found that when rendering the text using drawGlyphsForGlyphRange:atPoint:, I don't get the text where I expected. It is higher than I expect. Furthermore, when I draw a rectangle around the text (or try to) using the rectangle from usedRectForTextContainer:, the text is outside the rectangle (in short, the rectangle is where I expect it to be, but the text glyphs are not).
>>
>> Is there a secret incantation that I am missing?
>>
>> Thanks,
>>
>> Todd
>>
>> Basic code snippet:
>>
>> point = NSMakePoint(1.0, 1.0);
>> glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
>> usedRect = [layoutManager usedRectForTextContainer:textContainer];
>> usedRect.origin = point;
>>
>> [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:point];
>> [[NSBezierPath bezierPathWithRect: rect] stroke];
>> _______________________________________________
>>
>> 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
>
> _______________________________________________
>
> 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

_______________________________________________

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

  • Follow-Ups:
    • Re: text orientation/positioning with layout manager
      • From: Ross Carter <email@hidden>
References: 
 >text orientation/positioning with layout manager (From: Todd Heberlein <email@hidden>)
 >Re: text orientation/positioning with layout manager (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: iPhone puzzle about rotation
  • Next by Date: -[CALayer setContents:] slower in iOS 4.2?
  • Previous by thread: Re: text orientation/positioning with layout manager
  • Next by thread: Re: text orientation/positioning with layout manager
  • Index(es):
    • Date
    • Thread