DynaPDF Manual - Page 767
Previous Page 766 Index Next Page 768

Function Reference
Page 767 of 874
HFONT f = CreateFont(
-240,
// height of font
0,
// average character width
0,
// angle of escapement
0,
// base-line orientation angle
500,
// font weight
1,
// italic attribute option
0,
// underline attribute option
0,
// strikeout attribute option
Ansi_CHARSET,
// character set identifier
OUT_TT_ONLY_PRECIS,
// output precision
CLIP_DEFAULT_PRECIS, // clipping precision
ANTIALIASED_QUALITY, // output quality
FF_DONTCARE,
// pitch and family
"Arial")
// typeface name (Family Name)
nHeight
The GDI supports three modes how the font size or height can be specified. We want to discuss
negative values only because the other modes are not of interest for high precision output (positive
values specify the cell height of a font, this value must be converted by DynaPDF to determine the
wished font size). The font height we used in the example CreateFont() function call is defined as a
negative value. The absolute value of it is transformed to device units by the font mapper. We
choose a size of 240 units; this is a normal font size for a 1440 DPI output.
A negative font height in a CreateFont() function call is exactly the same as a positive height or size
in a SetFont() function call in DynaPDF (negative values are not supported by SetFont()).
However, GDI coordinates are normally upscaled because GDI functions support integer values
only. For example, if we want to use a font size of 12.74 units, we can only upscale the coordinate
system because it is impossible to define such a font size with a GDI function. That is the reason
why GDI drawings are defined in a specific resolution. GDI coordinates are never really device
independent.
However, to avoid issues with a fixed resolution the PDF format uses a completely different system
to produce device independent output. PDF coordinates and font sizes are expressed in floating
point units so that we can use our font size of 12.74 units directly. We do not need to upscale the
coordinate system and we don't need to consider whether the PDF file is drawn on a monitor or
printer. All the details about the output resolution are completely hidden for the user.
BTW - A PDF unit is 1/72 inch.
nWidth
The average character width (nWidth) is the same as horizontal text scaling in PDF (see
SetTextScaling()), but the calculation is completely different. The GDI uses the average character
width of a font to calculate the text scaling (the unscaled value is returned by the GDI function
GetTextMetrics() if nWidth was set to zero during font selection). So, the font must be selected into
Previous topic: How to use CJK encodings?, GDI Font selection in comparison to DynaPDF
Next topic: nEscapement, nOrientation, nWeight, fdwCharSet