• 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: advancementForGlyph problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: advancementForGlyph problem


  • Subject: Re: advancementForGlyph problem
  • From: "David F." <email@hidden>
  • Date: Sun, 2 May 2010 19:00:06 -0600

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@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: advancementForGlyph problem
      • From: steven Hooley <email@hidden>
  • Prev by Date: Prevent NSTableView deactivate when window active
  • Next by Date: Re: advancementForGlyph problem
  • Previous by thread: Prevent NSTableView deactivate when window active
  • Next by thread: Re: advancementForGlyph problem
  • Index(es):
    • Date
    • Thread