DynaPDF Manual - Page 523
Previous Page 522 Index Next Page 524
Function Reference
Page 523 of 860
GetTextWidth
Syntax:
double pdfGetTextWidth(
const PPDF* IPDF,
// Instance pointer
const char* AText) // Null-terminated text string
The function computes the width of a text string in horizontal writing mode and the height in
vertical writing mode. The graphics state parameters character spacing, word spacing, text scaling,
and the current font size are all considered. A font must be set before this function can be used.
The function computes the visible width of the string. This is the width excluding the last character
spacing. The bounding box of the string is the text width plus the current character spacing. This
behaviour must be taken into account when writing right aligned text with WriteFText(). Due to
certain formatting rules WriteFText() must use the real bounding box of the text.
Visible Text Width (character spacing = 5.0)
C h a r a c t e r S p a c i n g
Real Bounding Box (character spacing = 5.0)
C h a r a c t e r S p a c i n g
Remarks:
This function is implemented in an Ansi and Unicode compatible version.
CJK to Unicode code pages are supported by the Ansi version only because CJK strings must be
converted to Unicode beforehand. These conversion algorithms are available in the Ansi version
only. However, native CJK character sets are also supported with the wide string version in
combination with a CJK font. See SetFont() for further information.
Return values:
If the function succeeds the return value is the string width in un-scaled units. If the function fails
the return value is a negative error code.
GetTextWidth (Font API)
Syntax:
double fntGetTextWidth(
const void* IFont, // Pointer of the font object
const BYTE* Text,
// PDF Text string
UI32 Len,
// Length of the string
float CharSpacing, // Current character spacing
float WordSpacing, // Current word spacing
float TextScale)
// Current text scaling
The function can be used to calculate the width of a sub string that was returned by the content
parser (see ParseContent() for further information). The parameter IFont must be a valid pointer of a
Previous topic: GetTextRise, GetTextScaling
Next topic: GetTextWidthEx