On 27 Aug, 2013, at 13:46 , Graham Cox <graham....@bigpond.com> wrote:

> Parsing a PDF, I need to handle the Tf (set font) operator. The font 
> situation in PDF files is inordinately complicated, and reading the spec 
> alone is not really leading to the light-bulb moment.
> 
> Basically, when I get the Tf operator, I need to end up with a CGFontRef I 
> can use. I see a number of CGFontCreate… methods, none of which really fit 
> anything I can see in the PDF spec itself. Perhaps 
> CGFontCreateWithDataProvider is the "magic bullet" that just works behind the 
> scenes to make sense of the almost innumerable PDF variations, but I can't 
> see how I even get to the point where I could use it.
> 
> For example, one of my test files has a Tf operator that references a Font 
> resource C2_0, which returns a dictionary object like this:
> 
> 2013-08-27 12:08:10.303 PDFParser[43098:303] PDF Dictionary {
> 2013-08-27 12:08:10.303 PDFParser[43098:303] 
> 'BaseFont'=[Name]'JOZTES+DFHei-Lt-HK-BF',
> 2013-08-27 12:08:10.303 PDFParser[43098:303] 'DescendantFonts'=[Array],
> 2013-08-27 12:08:10.304 PDFParser[43098:303] 'Encoding'=[Name]'Identity-H',
> 2013-08-27 12:08:10.304 PDFParser[43098:303] 'Subtype'=[Name]'Type0',
> 2013-08-27 12:08:10.304 PDFParser[43098:303] 'ToUnicode'=[Stream],
> 2013-08-27 12:08:10.304 PDFParser[43098:303] 'Type'=[Name]'Font',
> 2013-08-27 12:08:10.304 PDFParser[43098:303] };
> 
> I see this in the PDF spec; it's just one among many possible font types and 
> formats, but I have no idea how to go from this to a CGFontRef.
> 
> Has anyone got any pointers or sample code on how the Tf operator should be 
> handled in general?

This area is a big pain (like such much other areas of the PDF spec…). 
CGFontCreateWithDataProvider is indeed what you will ultimately need, but 
getting there is tiresome. I'll message you privately with some non-production 
code that may help you get this off the ground.

-António

--------------------------------------------
I try to take one day at a time, but sometimes, several days attack me all at 
once!
--------------------------------------------


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to