DynaPDF Manual - Page 683

Previous Page 682   Index   Next Page 684

Function Reference
Page 683 of 777
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
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.
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
device context twice to calculate a text scaling, one time to determine the unscaled value, and a
second time to select the font with the wished value.
If a text should be scaled to 120% horizontally the calculation is as follows (C++):
GetTextMetrics(dc, &tm);
int nWidth = tm.AveCharWidth * 120 / 100;
Note that text scaling is an output attribute; the value is not used during font selection.
In PDF, text scaling is a separate property of the current graphics state so that you don't need to
determine the average character width of a font beforehand. Text scaling can be applied directly with
the function SetTextScaling() without any further calculation. So, if you want to scale a text to 120%
in PDF, you can simply call the function SetTextScaling() as follows:
pdfSetTextScaling(pdf, 120.0);
The angle of escapement specifies the output angle of a text string in tenths degrees. The output
angle of a string has nothing to do with a font, it is an output attribute. Rotated text can be printed
with the function WriteAngleText() with DynaPDF.

Previous topic: GDI Font selection in comparison to DynaPDF, nHeight

Next topic: nOrientation, nWeight, fdwCharSet, fdwPitchAndFamily, lpszFace