How is kerning encoded on embedded Adobe Type 1 fonts in PDF files?
Asked Answered
D

1

5

Adobe PDF reference talks about /Widths array and /FontFile stream, but Adobe Type 1 font programs (.pfb or .pfa files) don't include font metrics; they are included in font metric files (.afm or .pfm files) but these are not embedded in PDF file.

PDF can just encode char width metrics or it can encode kerning pair too? How?

Durston answered 19/8, 2013 at 0:20 Comment(1)
Kerning in PDFs is done by explicit offsets in the page content streams.Neology
N
8

If you study the section 9.4.4 of the PDF specification ISO 32000-1 (see below), you'll see that no special kerning information (e.g. extracted from the font program) are included in the calculation of the glyph displacement.

You'll also see, though, that there is a Tj value which denotes a number in a TJ array, if any, which specifies a position adjustment. This value is used to implement kerning.

E.g. that phrase "denotes a number in a TJ array, if any, which specifies a position adjustment" from the specification itself is set as:

[( de)-5.5(no)-5.5(te)-5.5(s a nu)-5.5(m)-5.7(b).5(e)-5.5(r).3( in a )]TJ
...

You see for example kerning applied in denotes between 'e' and 'n', 'o' and 't', and 'e' and 's'.

The section from the specification:

The section 9.4.4 referenced above

Neology answered 19/8, 2013 at 8:13 Comment(2)
So this is the only way and will be displayed the same on all PDF viewers? I must ensure that text line width will be consistent between different viewers and any software will try to get kerning info from another source (eg. kerning tables from an installed font program on the host system).Durston
So this is the only way - as this is from the specification, yes, this is how page content is rendered. will be displayed the same on all PDF viewers - Only on those implementing the PDF standard without bugs in this respect; that should mean each one but one never knows. any software will try to get kerning info from another source - There is one case to consider: If the PDF contains form elements without pre-created appearance streams, different viewers might differ in what they create as appearances. Form fields are not part of the regular page content.Neology

© 2022 - 2024 — McMap. All rights reserved.