I don't think I have ever worked on something type related without having, at some stage, to grub around in font tables. Cello, it turns out, is no different. The output file requires a subset of kerning pairs of the fonts used in the documents - to do this I need to get a set of all the kerning pairs that are defined a given font. Core Text won't give me the kerning pars but it has a function
CTFontCopyTable that will give me, via a
CFDataRef, a pointer to an arbitrary table in the font. All the fonts Core Text deals with are TrueType fonts, and those that are not (Type 1 postscript fonts) are cleverly packed up on the fly as synthetic true-type fonts.
CTFontCopyTable takes an options flag that allows you to screen out synthetic tables - should you wish.
So to get the kerning table of a font you:
CFDataRef kerningTable =
::CTFontCopyTable(font, kCTFontTableKern, kCTFontTableOptionNoOptions);
const UInt8 *kerningTablePtr = ::CFDataGetBytePtr(kerningTable);
The format of the truetype fonts and font tables can be found
here. Details of the kerning table can be found
here.
There are four different formats of kerning tables. I plan initially to support Format0 only
No comments:
Post a Comment