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

DynaPDF Manual - Page 539

Previous Page 538   Index   Next Page 540

Function Reference
Page 539 of 750
textWidth += fntGetTextWidth( m_GState.ActiveFont,
Source[i].Text + last,
j - last,
m_GState.CharSpacing,
m_GState.WordSpacing,
m_GState.TextScale);
x2 = textWidth;
y2 = 0.0;
Transform(m, x2, y2);
/*AddText(x1, y1,
x2, y2,
Source[i],
Kerning[i],
last,
j - last);*/
// Update the cursor position. More text can follow.
x1 = x2;
y1 = y2;
}
}
}
}
DynaPDF is delivered with several example projects which demonstrate how text coordinates must
be computed and how text can be extracted. The above code is a fragment of the example project
Text Coordinates which is delivered with all DynaPDF versions.
Text Scaling
Like character and word spacing the current text scaling is already considered in the text width that
is provided in all text callback functions. However, the value must be stored in the graphics state if
the width of a sub string must be computed. Text scaling is measured in percent of the original
unscaled text width.
Sub string coordinates
Sub string processing is somewhat more complicated because the width of a sub string cannot be
calculated from the Unicode string and one source character does necessarily correspond to one
Unicode character.
Simple fonts use one byte encodings where one source byte can be decoded to one or more Unicode
characters. CID fonts support also multi-byte encodings with fixed and variable code lengths. A
sequence of n source bytes can be decoded to m Unicode characters. So, there is no logical
relationship between the source and converted Unicode string.
If a text search algorithm should provide the coordinates of a found string, then it must be able to
find the position of the search text in the source string because it is not possible to calculate the string
width from the Unicode string. DynaPDF provides several helper functions to calculate the width of
 

Previous topic: Word Spacing

Next topic: Text Extraction or Text Search Algorithms