On Apr 30, 2010, at 5:08 AM, steven Hooley wrote:

>> The information I am getting back from advancementForGlyph doesn't
>> seem to be correct.  Here are the glyph bounds and advancement for
>> the capital letter 'A' in Georgia 36pt:
>> 
>> == A ==
>> bounds x: -0.720703
>> bounds y: 0.000000
>> bounds w: 25.699219
>> bounds h: 25.294922
>> advance w: 24.152344
>> advance h: 0.000000
>> 
>> The problem that I am seeing is that it looks like the advancement
>> should only be 23 (maybe ~23.2).  TextEdit appears to be using an
>> advancement of 23 and underlines and strikethroughs are being drawn
>> 23 pixels wide.
>> 
>> Any ideas on what I am doing/understanding wrong?
> 
> The information is 'correct', ie. it is was it is - the data encoded
> in the font scaled to your working size.
> 
> How on earth are you determining that it "looks like the advancement
> should only be ~23.2" ?

By counting pixels.

> "TextEdit appears to be using an advancement of 23" How have you
> determined this?

By counting pixels.

> If you have infact determined that TextEdit uses and advance of
> ~23.2px, what makes you think that this is more likely to be correct
> than the value encoded in the font, by the font designer?

I'm actually less concerned with "correct" and more concerned with "where is it 
coming from?".

> 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'.

Actually, if you draw underlines and strikethroughs based on advancement, then 
you can draw a glyph at a time and they line up quite well.  (Fractional 
positioning makes the lining up less than perfect, but it does work.  And if 
you Ctrl-Scrollwheel your screen you can even see the seams in TextEdit.)

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