• 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: Pixel-perfect migration from ATSUI to Core Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Pixel-perfect migration from ATSUI to Core Text


  • Subject: Re: Pixel-perfect migration from ATSUI to Core Text
  • From: Ken Thomases <email@hidden>
  • Date: Tue, 30 Aug 2016 21:01:11 -0500

On Aug 30, 2016, at 8:47 AM, Andreas Falkenhahn <email@hidden> wrote:
>
>> That said, when drawing strings, there are the functions
>> CGContextSetShouldSubpixelPositionFonts() and
>> CGContextSetAllowsFontSubpixelPositioning().  Those can be used to
>> turn off sub-pixel positioning of glyphs.  It may be that ATSUI
>> wasn't capable of that and so turning it off gets you the same positioning as ATSUI.
>
>> There doesn't seem to be a direct way to ask Core Text for the
>> measurements corresponding to that drawing mode.  So, you may need
>> to ask your CTLine for its CTRuns and then ask the CTRun for the
>> individual glyph advances.
>
> Hmm, I don't understand. The only CTRun APIs that take a CGContextRef are CTRunGetImageBounds()
> and CTRunDraw(). I'd have to use CTRunGetAdvances(), though, but this function doesn't accept
> a CGContextRef so I don't see how I should implement your suggestions...

I mentioned CGContext only to illustrate the point that there are two text-rendering modes, one that allows for sub-pixel glyph position (and thus advances) and one which doesn't.  The other part of what I said has nothing to do with CGContext.

I would have hoped there would be APIs built into Core Text that would measure the text as it would be rendered when sub-pixel glyph positioning isn't allowed, but there don't seem to be.  So, I suggested a way to compute it manually.  Get the individual glyph advances for the run and combine them, but only after applying ceil() or round() to them (I'm not sure which).

Regards,
Ken


_______________________________________________

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: Pixel-perfect migration from ATSUI to Core Text
      • From: Andreas Falkenhahn <email@hidden>
References: 
 >Re: Pixel-perfect migration from ATSUI to Core Text (From: Ken Thomases <email@hidden>)
 >Re: Pixel-perfect migration from ATSUI to Core Text (From: Andreas Falkenhahn <email@hidden>)

  • Prev by Date: Re: Swift changes in Xcode 8
  • Next by Date: Re: Drawing issue with translucent borderless NSWindow, initial content half stays
  • Previous by thread: Re: Pixel-perfect migration from ATSUI to Core Text
  • Next by thread: Re: Pixel-perfect migration from ATSUI to Core Text
  • Index(es):
    • Date
    • Thread