Copy link to clipboard
Copied
I have been tryingo to solve this puzzle for a while now but no luck so far. I am seeing differences between font metadata when directly embedded with Acrobat (or exported from InDesign) and a custom library (FPDF in this case). Let me explain it on a simple example of Kudryashev Headline Sans font.
Let's say I am creating a PDF document with an embedded font in Acrobat. I have the font imported in Windows and it gets embedded when saving the PDF. Here is how the the font looks like in the document itself:
<</Ascent 968/CapHeight 723/Descent -353/Flags 32/FontBBox[-479 -353 1116 968]/FontFamily(Kudryashev Headline Sans)/FontFile2 18 0 R/FontName/QDQMZQ+KudryashevHeadlineSans/FontStretch/Normal/FontWeight 400/ItalicAngle 0/StemV 68/Type/FontDescriptor/XHeight 481>>
Now I want to "reproduce" the same PDF programatically. I extracted all the TTF metadata and use it to embed font in PDF. Here is how the data looks like in the document:
<</Type /FontDescriptor /FontName /AAAAAA+KudryashevHeadlineSans /Ascent 770 /Descent -230 /CapHeight 723 /Flags 32 /FontBBox [-479 -353 1116 968] /ItalicAngle 0 /StemV 70 /MissingWidth 224 /FontFile2 6 0 R>>
As you may notice some values are completely different. Like Ascent, Descent and StemV. My first guess was that the way I exctracted the metadata out of the TTF is simply wrong so I decided to check how the data looks like in the TTF itself using FontForge:
As you can see, when it comes to Ascent and Descent the values shown by FontForge are the same I extracted programatically and used to generate the PDF with FPDF. But they differ to what I see in Acrobat generate PDF.
How is this possible? Where is this difference coming from? Or am I just missing something obvious here (I am kind of new to PDF/fonts topic)?
Copy link to clipboard
Copied
Maybe the value is the true ascent of the font subset embedded, rather than the per-font maximum. Just a thought.
Copy link to clipboard
Copied
Thank for the hint! Indeed, preflight analysis says "embedded (as a subset)". But is it possible that for all fonts the ascent is 770 and fo a subset it is 968? Same goes for descent -230 for all fonts but -353 for a subset? And in the and the FontBBox is the same in both cases?
Also, what would be part of that subset? I tried several different texts (incuding just one lower case letter or one upper case letter) and the values are always the same.
Can anyone explain how subsetting works? How I see it is not explicitly related to used fonts (at least this is what I can see so far).
Copy link to clipboard
Copied
Sounds like you have shown this isn't the issue. Have you confirmed that the meaning of PDF "ascent" and TTF "ascent" excactly correspond?
Copy link to clipboard
Copied
I did a bit more research and rendered PDFs with ApacheFOP. Interesting fact - the same font embedded by FOP looks exactly the same as the one from Acrobat or InDesign. Therefore my assumption is that there is something strange happening in FPDF.
Another example, when I try to extract the embedded font with FontForge the result is correct when it comes to PDFs generated by Acrobat/InDesign and for FPDF the app simply crashes. When extracted it with an online tool the resulting font is different than the original.
So, long story short - I don't understand what is happening when fonts get embedded but it seems that FPDF is doing it simply wrong. I will try out the PDFLib - hopefully it will handle fonts correctly.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more