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

Re: Creating CGFont from PDF Tf operator


  • Subject: Re: Creating CGFont from PDF Tf operator
  • From: Antonio Nunes <email@hidden>
  • Date: Tue, 27 Aug 2013 21:01:11 +0100

On 27 Aug, 2013, at 13:46 , Graham Cox <email@hidden> 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 (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


References: 
 >Creating CGFont from PDF Tf operator (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Tracking down NSNotification center sigaborts
  • Next by Date: Re: "Introducing ioscomponents.com"
  • Previous by thread: Creating CGFont from PDF Tf operator
  • Next by thread: Re: Creating CGFont from PDF Tf operator
  • Index(es):
    • Date
    • Thread