• 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
Creating CGFont from PDF Tf operator
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating CGFont from PDF Tf operator


  • Subject: Creating CGFont from PDF Tf operator
  • From: Graham Cox <email@hidden>
  • Date: Tue, 27 Aug 2013 14:46:02 +0200

OK, now I'm stumped.

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?


--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


  • Follow-Ups:
    • Re: Creating CGFont from PDF Tf operator
      • From: Marcel Weiher <email@hidden>
    • Re: Creating CGFont from PDF Tf operator
      • From: Antonio Nunes <email@hidden>
  • Prev by Date: Cocoa + Automator : service to generate text files not working
  • Next by Date: Re: handleGetURLEvent getting called after applicationDidFinishLaunching
  • Previous by thread: Re: Cocoa + Automator : service to generate text files not working
  • Next by thread: Re: Creating CGFont from PDF Tf operator
  • Index(es):
    • Date
    • Thread