Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 453

Previous Page 452   Index   Next Page 454

Function Reference
Page 453 of 750
GetTextWidth (Font API)
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
font object that was provided in the TSetFont callback function. Note that this function is optimized
for speed and does not use the normal error handling of DynaPDF. The parameters CharSpacing,
WordSpacing, and TextScale must be taken from the current graphics state.
The function returns the real text width of a string:
Visible Text Width (character spacing = 5.0)
C h a r a c t e r S p a c i n g
Real Text Width (character spacing = 5.0)
C h a r a c t e r S p a c i n g
Return values:
If the function succeeds the return value is the string width measured in text space. If the parameter
IFont is set NULL the return value is 0.0.
double pdfGetTextWidthEx(
const PPDF* IPDF,
// Instance pointer
const char* AText, // Text string
UI32 Len)
// Length of the string in characters
The function computes the width of a text string. 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() uses the bounding box of a text string to output text.
Visible Text Width (character spacing = 5.0)
C h a r a c t e r S p a c i n g

Previous topic: GetTextWidth

Next topic: GetURIAction