DynaPDF Manual - Page 425
Previous Page 424 Index Next Page 426
Function Reference
Page 425 of 839
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;
pdfBezier_2_3(PDF, x1, y1, x, y);
break;
}
break;
case 4:
switch(++idx)
{
case 1: x1 = x; y1 = y; break;
case 2: x2 = x; y2 = y; break;
case 3:
idx = 0;
pdfBezier_1_2_3(PDF, x1, y1, x2, y2, x, y);
break;
}
break;
default: throw "Unknown error!";
}
}
pdfClosePath(PDF, fmFill);
}
void DrawTextOutline(const PPDF* PDF, const BYTE* Text, SI32 Len)
{
SI32 i, idx, size;
TPDFGlyphOutline glyph;
double x, y, scale, fontSize;
pdfCreateNewPDF(PDF, "test.pdf");
pdfSetPageCoords(PDF, pcTopDown);
pdfAppend(PDF);
memset(&glyph, 0, sizeof(glyph));
// The font size is NOT considered by GetGlyphOutline()!
pdfSetFont(PDF, "Arial", fsRegular, 10.0, false, cp1252);
x = y = 50.0;
fontSize = 40.0f;
Previous topic: C, C++, Delphi, C#, VB 6, VB .Net, PHP, Outline format
Next topic: GetGoToAction