DynaPDF Manual - Page 605

Previous Page 604   Index   Next Page 606

Function Reference
Page 605 of 839
{
double x1 = 0.0;
double y1 = 0.0;
double x2 = 0.0;
double y2 = 1.0;
Transform(M, x1, y1);
Transform(M, x2, y2);
if (y1 > y2)
return -CalcDistance(x1, y1, x2, y2);
else
return CalcDistance(x1, y1, x2, y2);
}
// Multiply two matrices. Note that matrix multiplications are not
// commutative. It is a difference whether the matrix M1 is multiplied
// with M2 or vice versa!
TCTM MulMatrix(TCTM &M1, TCTM &M2)
{
TCTM retval;
retval.a = M2.a * M1.a + M2.b * M1.c;
retval.b = M2.a * M1.b + M2.b * M1.d;
retval.c = M2.c * M1.a + M2.d * M1.c;
retval.d = M2.c * M1.b + M2.d * M1.d;
retval.x = M2.x * M1.a + M2.y * M1.c + M1.x;
retval.y = M2.x * M1.b + M2.y * M1.d + M1.y;
return retval;
}
// Transform a point with a matrix
void Transform(TCTM &M, double &x, double &y)
{
double tx = x;
x = tx * M.a + y * M.c + M.x;
y = tx * M.b + y * M.d + M.y;
}
Text Coordinates and Metrics
As mentioned earlier text coordinates are defined in text space. The transformation from text space
to user space is achieved by multiplying the text matrix with the one of the current graphics state.
However, the graphics state contains several text related parameters which require some further
explanation. The following sub-clauses describe in detail in which coordinate space these
parameters are defined, how they can be transformed to user space, and how text metrics like the
text width must be interpreted.
Font Size
The current font size, which is a parameter of the graphics state, is defined in text space. The visible
font size is measured in user space, so, the value of the graphics state is not directly usable.
 

Previous topic: Helper Functions

Next topic: Text Width