45
98
Chapter 4: Text Handling
Temporarily disabling kerning may be useful, for example, for tabular figures when
the kerning data contains pairs of figures, since kerned figures wouldn’t line up in a
table.
Kerning is applied in addition to any character spacing, word spacing, and horizontal
scaling which may be activated. Note, however, that the combination of horizontal
spacing and kerning only works correctly in Acrobat 4.05 and above, but not any older
versions.
PDFlib does not have any limit for the number of kerning pairs in a font.
4.6.3 Text Variations
Artificial font styles. Bold and italic variations of a font should normally be created by
choosing an appropriate font. In addition, PDFlib also supports artificial font styles:
based on a regular font Acrobat will simulate bold, italic, or bolditalic styles by embold-
ening or slanting the base font. The aestethic quality of artificial font styles does not
match those of real bold or italic fonts which have been fine-tuned by the font designer.
However, in situations where a particular font style is not available directly, artificial
styles can be used as a workaround. In particular, artificial font styles are useful for the
standard CJK fonts which support only normal fonts, but not any bold or italic variants.
Note Using the fontstyle feature for fonts other than the standard CJK fonts is not recommended.
Due to restrictions in Adobe Acrobat, artificial font styles work only if all of the follow-
ing conditions are met:
>The base font is a TrueType or OpenType font, including standard and custom CJK
fonts. The base font must not be one of the PDF core fonts (see Section 4.3.2, »Font
Embedding«, page 81).
>The encoding is winansi, macroman, or one of the predefined CJK CMaps listed in Ta-
ble 4.6 (since otherwise PDFlib will force font embedding).
>The embedding option must be set to false.
>The base font must be installed on the target system where the PDF will be viewed.
While PDFlib will check the first three conditions, it is the user’s responsibility to ensure
the last one.
Artificial font styles can be requested by using one of the normal (no change of the
base font), bold, italic, or bolditalic keywords for the fontstyle option of PDF_load_font( ):
PDF_load_font(p, "HeiseiKakuGo-W5", 0, "UniJIS-UCS2-H", "fontstyle bold");
Underline, overline, and strikeout text. PDFlib can be instructed to put lines below,
above, or in the middle of text. The stroke width of the bar and its distance from the
baseline are calculated based on the font’s metrics information. In addition, the current
values of the horizontal scaling factor and the text matrix are taken into account when
calculating the width of the bar. PDF_set_parameter( ) can be used to switch the under-
line, overline, and strikeout feature on or off as follows:
PDF_set_parameter(p, "underline", "true");
/* enable underlines */
The current stroke color is used for drawing the bars. The current linecap and dash pa-
rameters are ignored, however. Aesthetics alert: in most fonts underlining will touch
descenders, and overlining will touch diacritical marks atop ascenders.