Re: Creating CGFont from PDF Tf operator
Re: Creating CGFont from PDF Tf operator
- Subject: Re: Creating CGFont from PDF Tf operator
- From: Graham Cox <email@hidden>
- Date: Wed, 28 Aug 2013 16:02:25 +0200
On 28/08/2013, at 2:22 PM, Marcel Weiher <email@hidden> wrote:
> Well, first you have a /Font. This should contain a reference to a /FontDescriptor. If the font is embedded in the file, then you have a /FontFile reference ( or /FontFile1, /FontFile2, /FontFile3), which then points to the PDF Stream containing the actual font.
Right. With some help from Antonio Nunes I've got this part working pretty well.
> If there is no /FontFile, the font is not embedded and you need to figure out where to get the font to use (by name) or supply a fallback font, which has to match the encoding and metrics.
Any of the 14 "standard" fonts are easy enough as well.
I have not yet attempted to create a font using the descriptor - in fact I'm not seeing any test cases in any of my PDF files that trigger this. It might be rare enough to leave alone for now.
> Ahh, a Type0 font. Those are fun!
Well, I found that the /DescendantFonts here contains another font dictionary, and by passing it around (recursing) it deals with that just as for any of the other font types.
It seems overall that I was right in that once you can get to a stream (font file) or a name, you're home and dry. CGFontCreateWithDataProvider obviously implements an awful lot of magic to deal with the really nasty stuff.
One final follow-up question though - how do I go from the character strings referenced by Tj and friends to an array of glyphs? I see a great function in Core Text: CTFontGetGlyphsForCharacters, but I'm not sure whether I can simply use a CGFontRef here or whether using Core Text is the right way ahead. Since my ultimate aim isn't to render the PDF but to create a set of corresponding editable objects, it might be possible to assemble an NSAttributedString object and try and figure out what its bounding box would have ended up as had it been rendered. But doing that seems to need glyph measurement so I'm back to that. Going in circles...
--Graham
_______________________________________________
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