DynaPDF Manual - Page 691

Previous Page 690   Index   Next Page 692

Function Reference
Page 691 of 787
GDI Font selection in comparison to DynaPDF
The Windows GDI selects a font in another way than DynaPDF does. Let us see how a font can be
selected with the GDI function CreateFont() and where are the differences in comparison to
DynaPDF:
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.
 

Previous topic: How to use CJK encodings?

Next topic: nWidth, nEscapement, nOrientation, nWeight

Start Chat