On Apr 30, 2010, at 7:20 AM, Graham Cox wrote:

> 
> On 30/04/2010, at 9:08 PM, steven Hooley wrote:
> 
>>> From your later response it seems like your question is really
>> regarding drawing strikethroughs and underlines. If so, the strike
>> through and underline are not part of the glyph or font - they are
>> just a line drawn from the start point of a range of glyphs to the end
>> point of a range of glyphs. You cannot draw them piecemeal, a glyph at
>> a time, and expect them to perfectly match up without overlap or
>> underlap (apologies for making up a word), as the amount that any 2
>> glyphs overlap is particular to those 2 glyhps. ie. The strikethrough
>> of an 'A' followed by a 'V' would need to be a different length than
>> that of an 'A' followed by a 'j'.
> 
> 
> Not that this will tell you anything about what Cocoa does, but when I had to 
> implement underlines and strikethroughs for text-on-path in DrawKit, I did so 
> by working a line at a time and knocking out any places where descenders 
> would hit the line. For text-on-path, drawing a line per glyph looks 
> absolutely terrible, being straight and not curved, and having gaps where the 
> character curves away from its neighbour.
> 
> I would imagine that for performance reasons as well as aesthetic, Cocoa 
> draws whole lines for strikethroughs and underlines as well.

If you zoom your screen by Ctrl-Scrollwheel with TextEdit open, you can see 
that characters (and their strikethrough/underline) appear to be drawn 
individually when the character is first inserted (you can see the seams in the 
strikethrough/underline between characters) but then the line appears to get 
redrawn all at once about a second later and the seams (mostly) disappear.

> I did also discover that relying on the values exactly returned by a font 
> didn't always give similar results to Cocoa's underline positioning - I never 
> did quite work out its metrics but arrived at certain fudge factors 
> empirically that gave almost identical results with most fonts.

I was able to get correct metrics for glyphs with ATSUI.  But since that is now 
deprecated I'm rewriting my code to use Cocoa text.  I wish I could say that 
the rewrite was easy, but I'm dying a death of 1000 papercuts.

David

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to