• 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
Laying out superscripted text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Laying out superscripted text


  • Subject: Laying out superscripted text
  • From: Graham Cox <email@hidden>
  • Date: Thu, 28 May 2009 17:19:07 +1000

I have code that lays out text on a path. It essentially boils down to the technique given in the Text Layout Programming Guide example code (Circle text) of setting up a transform before letting the layout manager get on with its normal work, done by calling -[NSLayoutManager drawGlyphsForGlyphRange:atPoint:]; where the point is calculated from the -locationOfGlyphAtIndex: method (each glyph has to be drawn individually for obvious reasons, so the glyph range is always length 1)

This works great for almost everything you can do with an attributed string, but doesn't handle superscripts properly. Any super- or subscripted glyph always ends up on the baseline.

I have tried two things so far:

a) ask the typesetter, using -[NSTypesetter baselineOffsetInLayoutManager:glyphIndex:];

That produces nothing different for the superscripted characters.

b) going back to the original string's superscript attribute. That could work, since I have complete control over the baseline for each character. However, the superscript attribute is an integer which I understand to mean n units of "superscriptness" in proportion to h, where h is ??? lineheight? font height? I can't find any information on how this value can be turned into a baseline position.

So that would be good to know if anyone can help. That still leaves me mystified as to why the layout manager doesn't "just work" though.

--Graham


_______________________________________________

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: Laying out superscripted text
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: Booleans
  • Next by Date: Bluetooth serial examples
  • Previous by thread: Re: Booleans
  • Next by thread: Re: Laying out superscripted text
  • Index(es):
    • Date
    • Thread