• 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: A Tab after 4 SPACEs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Tab after 4 SPACEs


  • Subject: Re: A Tab after 4 SPACEs
  • From: glenn andreas <email@hidden>
  • Date: Thu, 27 Mar 2008 11:33:17 -0500


On Mar 27, 2008, at 11:12 AM, Gerriet M. Denkmann wrote:


On 27 Mar 2008, at 10:08, Uli Kusterer wrote:
On 27.03.2008, at 09:32, Gerriet M. Denkmann wrote:
float widthOfTab = [usedFont advancementForGlyph:(NSGlyph)' '].width * 4;


I'm pretty new to the text engine myself, but I don't think an NSGlyph can be generated by typecasting a char. Since Monaco or Courier are monospaced, it just so happens that you get the same width as the space would be. But the glyph with number 0x20 is probably a completely different width than the glyph corresponding to a space in other languages.

Yes. You are certainly right. Silly mistake of mine.
There should be something like: -[NSFont glyphForChar: (NSString *)aString ] which returns NSNotFound if the font does not contain the first char in aString.
But I did not find any such method.

You are assuming that there is a one-to-one correspondence between characters and glyphs. There isn't. Consider simple cases such as ligatures (the way that "f" and "l" may combine to a single character where the top of the "f" blends in with the top of the "l"), or degenerate cases like the way that the entire word "Zapfino" in the Zapfino font is a single glyph. It gets worse once you consider internationalization - many languages have different glyphs depending on if the character is the first character of a word, in the middle, or at the end of the word (so if you get a glyph for a single character, you've got a 66% chance of getting the wrong one).




Glenn Andreas                      email@hidden
 <http://www.gandreas.com/> wicked fun!
Cardographer | the custom playing card designer


_______________________________________________

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


References: 
 >A Tab after 4 SPACEs (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: A Tab after 4 SPACEs (From: Uli Kusterer <email@hidden>)
 >Re: A Tab after 4 SPACEs (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Leopard on PPC
  • Next by Date: NSScroller question
  • Previous by thread: Re: A Tab after 4 SPACEs
  • Next by thread: Re: A Tab after 4 SPACEs
  • Index(es):
    • Date
    • Thread