pdf::Font Class Reference
[Fonts]

The Font class. More...

#include <Font.hh>

List of all members.

Public Member Functions

virtual std::string BaseName () const =0
 Return the base name of a font.
virtual const GlyphGetGlyph (wchar_t ch) const =0
 Return the glyph for the corresponding character code.
virtual unsigned UnitsPerEM () const =0
 Return the number of font unit in the EM square.
virtual double FromFontUnit (unsigned val) const =0
 Return the width of the glyph in PDF glyph unit.

Detailed Description

This class represents a font in the PDF document. It can be created by reading a PDF document which contain some fonts, or by manually creating by a font file. It provides access to the Glyph in the font.


Member Function Documentation

virtual std::string pdf::Font::BaseName (  )  const [pure virtual]

This function returns the PostScript name of the font. For Type 1 fonts, this is usually the value of the FontName entry in the font program. For TrueType fonts, it is returned by the FT_Get_Postscript_Name() function in FreeType. It will be used for displaying the font's name for client applications.

Returns:
The base name of a font.
virtual double pdf::Font::FromFontUnit ( unsigned  val  )  const [pure virtual]

Call this function to convert the lengths in font unit to PDF glyph unit. The PDF glyph unit is 1/1000 of user space, which is 1/72 inch. I.e. if this function returns 72000, then it is one inch. This value must be further multiplied by the font size in points to get the real device-independent size.

Parameters:
val The value in font unit to be convert to glyph unit.
Returns:
The converted value in glyph unit.
virtual const Glyph* pdf::Font::GetGlyph ( wchar_t  ch  )  const [pure virtual]

This function will search the glyph for the given character code. If there is no glyph defined for this character in the font, it will return 0.

Parameters:
ch The unicode value of the character.
Returns:
A point to the glyph, or 0 if the glyph in absent in the font.
virtual unsigned pdf::Font::UnitsPerEM (  )  const [pure virtual]

In creating the glyph outlines, a type designer uses an imaginary square called the EM square. Typically, the EM square can be thought of as a tablet on which the characters are drawn. The square's size, i.e., the number of grid units on its sides, is very important for two reasons:

  • It is the reference used to scale the outlines to a given text dimension. For example, a size of 12pt at 300x300 dpi corresponds to 12*300/72 = 50 pixels. This is the size the EM square would appear on the output device if it was rendered directly. In other words, scaling from grid units to pixels uses the formula:

pixel_size = point_size * resolution / 72 pixel_coord = grid_coord * pixel_size / EM_size

  • The greater the EM size is, the larger resolution the designer can use when digitizing outlines. For example, in the extreme example of an EM size of 4 units, there are only 25 point positions available within the EM square which is clearly not enough. Typical TrueType fonts use an EM size of 2048 units; Type 1 PostScript fonts have a fixed EM size of 1000 grid units but point coordinates can be expressed as floating values.

The documentation for this class was generated from the following file:

Hosted by SourceForge Logo