Re: Getting glyphs and their outlines
Re: Getting glyphs and their outlines
- Subject: Re: Getting glyphs and their outlines
- From: Allan Odgaard <email@hidden>
- Date: Mon, 29 Mar 2004 21:04:52 +0200
On 29. Mar 2004, at 19:01, Steve Sims wrote:
[...] it seems that all of these samples are Carbon applications, and
so none use the Cocoa APIs for doing equivalent things.
NSLayoutManager, NSGlyphGenerator, NSTypeSetter etc. seems to be the
Cocoa-version of ATSUI. I am not particularly fond of ATSUI, but I
must confess that I favor it over the Cocoa offerings :-/
So my question is simply how do I, in a Cocoa-friendly manner, get a
glyph for a single character?
Depends a little... if you want a glyph, and you know which glyph you
are after, you can use NSFont's glyphWithName: -- although the
documentation does not mention how the glyphs are named, from
experience they seem to be taken from the font, which use the
postscript names for the glyphs. A table which maps from postscript
glyph names to unicode can be found here:
http://partners.adobe.com/asn/tech/type/glyphlist.txt
The advice in the documentation is to look up the glyphs on your own,
and that would involve parsing font tables obtained using ATS -- I
honestly do not know what Apple was thinking when putting that info in
the documentation, as this is *not* a trivial task since most Mac fonts
do not contain a unicode mapping, so one has to heuristically work with
whatever else the font has to offer (e.g. postscript tables, old-style
Mac "script" encodings etc.).
That said, you can make the layout manager (NSLayoutManager) perform a
layout on a character string, this will include converting the
characters into glyphs, and it does allow you to read these glyphs
afterwards -- this is most likely the recommended way -- it requires a
bit of setup, and also you should be aware that character to glyph
mapping is not always a trivial one-to-one mapping. For example writing
"Risumi" may result in 8 glyphs (the 'e' with an accent can be made
using combining glyphs) where as "Figure" may only result in 5 glyphs
(F + i may have a special ligature glyph) etc.
** Cocoa FAQ: <
http://www.alastairs-place.net/cocoa/faq.txt> **
_______________________________________________
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.