DynaPDF Manual - Page 608

Previous Page 607   Index   Next Page 609

Function Reference
Page 608 of 839
// Transform the text matrix to user space
TCTM m = MulMatrix(m_GState.Matrix, *Matrix);
Transform(m, x1, y1); // Start point of the text record
// Word spacing applies to simple fonts only.
if (m_GState.FontType != ftType0)
{
UI32 i, j, last;
double x2 = 0.0;
double y2 = 0.0;
double textWidth = 0.0;
for (i = 0; i < Count; i++)
{
j
= 0;
last = 0;
// Consider kerning space
if (Source[i].Advance != 0.0f)
{
textWidth -= Source[i].Advance;
x1 = textWidth;
y1 = 0.0;
// Update the cursor position
Transform(m, x1, y1);
}
// Scan for spaces
while (j < Source[i].Length)
{
if (Source[i].Text[j] != 32)
++j;
else
{
// A space was found
if (j > last)
{
// The text must be taken from the Source array!
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;
// Calculate the end point.
Transform(m, x2, y2);
// We have now the exact start and end coordinate of the
// text's baseline. The text could now be written to a
// file or added to a list of text records depending on
// how the algorithm processes text. Note that the
// string length in the source and Unicode (Kerning)
 

Previous topic: Character Spacing, Word Spacing

Next topic: Text Scaling, Sub string coordinates