[Drawkit] Another text issue in non-flipped drawings

Graham Cox graham.cox at bigpond.com
Thu Jun 4 04:56:24 PDT 2009


On 04/06/2009, at 12:32 PM, Allan Daly wrote:

> As you can see, I'm creating a text string with line breaks and then  
> sending it to a new DKTextShape to be added to a drawing. What  
> happens is that in a not-flipped drawing the text gets displayed  
> bottom line at the top and top line at the bottom. The text is  
> readable and displays correctly, just wrong-way top to bottom. Check  
> out the attached PDF.
>


Hi Alan,

This is exactly the problem with NSLayoutManager. It assumes a flipped  
context and lays out lines in what it thinks is top-down order. In an  
un-flipped context that ends up as bottom-up order. The glyphs  
themselves end up right-way up because the actual rendering correctly  
takes into account whether the context is flipped or not.

As far as I can see there's no simple way to fix this without  
subclassing, but I think the subclass should be fairly  
straightforward. All it needs to do is to temporarily flip the context  
(using a suitable transform) just before performing layout so that it  
thinks it's drawing into a top-down context as usual. No doubt there  
will be a few unexpected problems along the way - I keep finding them  
with text!

I'll also try asking the question about this on the Cocoa-Dev list,  
though to be honest I find the information coming back from the text  
team is distinctly minimal and rarely helpful.

--Graham




More information about the Drawkit mailing list