DynaPDF Manual - Page 440

Previous Page 439   Index   Next Page 441

Function Reference
Page 440 of 860
C#, VB 6, VB .Net, PHP
The function returns the outline already in the first function call.
Note that not all glyphs have an outline. A space character, for example, has no outline and
therefore the size can be zero. The function returns normalized outlines scaled to a font size of 1000
units.
Outline format
The member Outline of the TPDFGlyphOutline structure contains coodinates encoded as 24.6 bit
fixed integer values. The remaining 2 bits contain the type of point or corresponding command that
was returned:
TI32Point &p = glyph.Outline[i];
UI32 cmd = ((p.y & 3) << 2) | (p.x & 3);
// Extract the command
SI32 x
= p.x >> 2;
// Remove the command. Result = 24.6 bit fixed point value!
SI32 y
= p.y >> 2;
// Remove the command. Result = 24.6 bit fixed point value!
double fx = x / 64.0;
// Conversion to PDF units
double fy = y / 64.0;
// Conversion to PDF units
cmd == 1 // MoveTo
cmd == 2 // LineTo
cmd == 3 // Bezier_2_3
// One more point follows
cmd == 4 // Bezier_1_2_3 // Two more points follow
Other values as listed above cannot occur and must be treated as an error.
Return values:
If the function succeeds the return value is the size of the outline in points. If the function fails the
return value is a negative error code.
Example (C++):
void DrawGlyph(const PPDF* PDF, double PosX, double PosY, double FontSize, TPDFGlyphOutline &Outline)
{
SI32 i, idx = 0, cmd, size = Outline.Size;
double x, y, x1=0.0, y1=0.0, x2=0.0, y2=0.0;
if (!size) return;
double fs = FontSize / 1000.0;
double s = fs / 64.0;
for (i = 0; i < size; i++)
{
TI32Point &p = Outline.Outline[i];
cmd = ((p.y & 3) << 2) | (p.x & 3);
x
= PosX + (p.x >> 2) * s;
y
= PosY - (p.y >> 2) * s; // Variant for top down coordinates (+ otherwise).
switch(cmd)
{
case 1: pdfMoveTo(PDF, x, y); break;
case 2: pdfLineTo(PDF, x, y); break;
case 3:
switch(++idx)
{
case 1: x1 = x; y1 = y; break;
case 2:
idx = 0;
 

Previous topic: GetGlyphOutline, C, C++, Delphi

Next topic: GetGoToAction