DynaPDF Manual - Page 678

Previous Page 677   Index   Next Page 679

Function Reference
Page 678 of 777
Unicode format in TrueType and OpenType fonts. However, most available fonts can be selected
with the Ansi version of SetFont() too because a usual font name contains no special characters.
A family name is not unique; it specifies the font family and not a specific font of a given style.
The combination of the family name and the font style identifies a font. For example, the font Arial is
available in several different styles such as Regular, Bold, Italic, or BoldItalic. The style information
Bold, Italic, and so on is not part of the font name. That is the reason why the style is a separate
parameter of SetFont().
Each font style is physically stored in a separate font file. However, if a requested style is not
available, SetFont() emulates the missing style if a compatible variant can be found. The emulation of
bold and italic font styles can be disabled with SetFontWeight() and SetItalicAngle().
Full name
The full name is a unique font name that identifies a font exactly. The full name is a combination of
the family name plus the style name, e.g. "Arial Bold Italic". This is the name that Windows exposes
to users. The parameter Style is ignored when selecting fonts via the full name.
TrueType and OpenType fonts can contain many localized full names. DynaPDF loads all these
language variants so that they can be used independent of the current locale.
PostScript name
The postscript name should be a unique name that identifies a font exactly. However, it is known
that certain font vendors deliver fonts with incorrectly named style variants, i.e. the same postscript
name can be assigned to condensed and expanded versions. In such a case the postscript name is not
unique and avoids correct font selection.
It is usually better to select fonts via the full name since this name seems to be unique in most fonts.
Font Styles
The parameter Style specifies the font style variant that should be loaded from a given font family. A
font style is a 32 bit unsigned integer that is encoded as follows:
Bits 0..7
// Style bits fsItalic, fsUnderlined, fsStriked
Bits 8..19
// Width class (1..9) -> Defined for future use
Bits 20..31 // Font Weight (100..1000)
The width class and font weight can be converted to a style constant with the macros WidthToStyle()
and WeightToStyle():
#define WidthToStyle(w)
((w) << 8)
#define WeightToStyle(w)
((w) << 20)
// Corresponding macros to extract the values
#define WidthFromStyle(s) (((s) & ~0xFFF2D00F) >> 8)
#define WeightFromStyle(s)(((s) & ~0xC00FFFFF) >> 20)

Previous topic: Font enumeration, Font Search Order, Font names, Family name

Next topic: Supported font formats, Font Subsetting, Font Embedding, The 14 Standard Fonts