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

DynaPDF Manual - Page 380

Previous Page 379   Index   Next Page 381

Function Reference
Page 380 of 750
The function returns the outline of a glyph of the active font. The usage is slightly different
depending on the used programming language:
C, C++, Delphi
The function must be called twice, the first time with the parameter Outline set to NULL or nil to
determine the size of the glyph outline (the function returns the number of points in this case). The
member Outline of the TPDFGlyphOutline structure can now be allocated and the function can be
called again. See example below the function description for further information.
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);
 

Previous topic: GetGlyphOutline

Next topic: GetGoToRAction