10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.5 Font Metrics and Text Variations5.5.1 Font and Glyph MetricsText position. PDFlib maintains the text position independently from the currentpoint for drawing graphics. While the former can be queried via the textx/texty parameters,the latter can be queried via currentx/currenty.Glyph metrics. PDFlib uses the glyph and font metrics system used by PostScript andPDF which shall be briefly discussed here.The font size which must be specified by PDFlib users is the minimum distance betweenadjacent text lines which is required to avoid overlapping character parts. Thefont size is generally larger than individual characters in a font, since it spans ascenderand descender, plus possibly additional space between lines.The leading (line spacing) specifies the vertical distance between the baselines of adjacentlines of text. By default it is set to the value of the font size. The capheight is theheight of capital letters such as T or H in most Latin fonts. The xheight is the height oflowercase letters such as x in most Latin fonts. The ascender is the height of lowercaseletters such as f or d in most Latin fonts. The descender is the distance from the baselineto the bottom of lowercase letters such as j or p in most Latin fonts. The descender isusually negative. The values of xheight, capheight, ascender, and descender are measuredas a fraction of the font size, and must be multiplied with the required font size beforebeing used.The gaplen property is only available in TrueType and OpenType fonts (it will be estimatedfor other font formats). The gaplen value is read from the font file, and specifiesthe difference between the recommended distance between baselines and the sum ofascender and descender.PDFlib may have to estimate one or more of these values since they are not guaranteedto be present in the font or metrics file. In order to find out whether real or estimatedvalues are used you can call PDF_info_font( ) to query the xheight with the optionfaked. The character metrics for a specific font can be queried from PDFlib as follows:font = p.load_font("Times-Roman", "unicode", "");capheight = p.info_font(font, "capheight", "");ascender = p.info_font(font, "ascender", "");Fig. 5.1 Font and character metricsfont sizecapheightascenderbaselinedescender112 Chapter 5: Font Handling

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!