• 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: Getting glyphs and their outlines
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting glyphs and their outlines


  • Subject: Re: Getting glyphs and their outlines
  • From: Glenn Andreas <email@hidden>
  • Date: Mon, 29 Mar 2004 13:16:55 -0600

At 12:01 PM -0500 3/29/04, Steve Sims wrote:
Hi gang,

I want to do something that I feel is fairly simple, namely get a glyph for a character in a particular font, and then grab its outline.

Funny, just the other day I thought the exact same.

Of course outline graphics are represented as NSBezierPath objects. Getting outlines the ATSUICurveAccessDemo way would seem to be a virtual duplication of NSBezierPath's appendBezierPathWithGlyph:inFont: call and I hate to reinvent the wheel. The only problem is this call takes an NSGlyph, and I can't see how to get the glyph for a particular character. I've looked everywhere I can think this would be, like NSGlyph, NSFont, NSString, etc., but haven't found it. I'm probably overlooking the obvious...

You're not, unfortunately. There is no "obvious" routine mapping between a "character" and a "glyph" becuase, well, there's no obvious mapping between characters and glyphs. For example, consider the case of glyphs that are formed by the combination of letters, like "fl" (where the "l" is joined with the "f"), or the two unicode character sequence for a decomposed umlaut (so it might be "lower case e", "umlaut", which can be translated to a single glyph in some font, or the complete opposite can happen where a "lower case e with umlaut" gets converted to two glyphs - one for the "e" and one for the umlaut").

However, doing what it sounds like you want isn't all that difficult, it just requires a couple of steps.

So my question is simply how do I, in a Cocoa-friendly manner, get a glyph for a single character?

The easiest way is to set up a NSLayoutManager object with a string containing your text in a particular font, and then calling glyphAtIndex (and then appendBezierPathWithGlyph:inFont:). There may, of course, not be the same number of glyphs as there are characters. Also note that this will cause problems if the glyph isn't represented in the font (for example, a given font may not have that character, like some funky symbol, and instead a different font is used, being substituted transparently), but for simple things it should work fine.


--
Glenn Andreas email@hidden mondo blobbo, Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Getting glyphs and their outlines (From: Steve Sims <email@hidden>)

  • Prev by Date: Re: Getting glyphs and their outlines
  • Next by Date: Re: returning nil on initialization
  • Previous by thread: Re: Getting glyphs and their outlines
  • Next by thread: NSOutlineView subclass
  • Index(es):
    • Date
    • Thread