true type fonts - What is the formula to get x, y coordinates from a truetype b-spline curve? -


what formula draw line in x, y space given b-spline coordinates in truetype font?

please note truetype allows bspline curves , straight lines within glyph definition.

if need change these commands series of moveto's , lineto's can use following:

  1. convert truetype data list of hinted coordinates. os can (following code uses windows apis).

  2. walk coordinates , translate curves lines (see code sniplet below):

    procedure tglyphevaluator.evaluatefrombuffer( action: tglyphevaluatoraction ); var     h                                   : ttpolygonheader;     c                                   : ttpolycurve;     points                              : array of tpointfx;     p, pe                               : dword;     i, j                                : integer;     f                                   : double;     pa, pb, pc                          : tpoint; begin     setlength( points, 10 );     p := 0;     repeat         // eat polygon header         move( fbuffer[ p ], h, sizeof( h ) );         if h.dwtype <> tt_polygon_type break;          // sanity check!         pe := p + h.cb;         inc( p, sizeof( h ) );         points[ 0 ] := h.pfxstart;         // eat curve records         while p < pe begin             // curve record             move( fbuffer[ p ], c, sizeof( c ) - sizeof( tpointfx ) );             inc( p, sizeof( c ) - sizeof( tpointfx ) );              // points curve record             if length( points ) < c.cpfx + 1 setlength( points, c.cpfx + 1 );             move( fbuffer[ p ], points[ 1 ], sizeof( tpointfx ) * c.cpfx );             inc( p, sizeof( tpointfx ) * c.cpfx );              case c.wtype of                 tt_prim_line: begin                         moveto( action, points[ 0 ].x.value, points[ 0 ].y.value );                         := 1 c.cpfx                             lineto( action, points[ ].x.value, points[ ].y.value );                     end;                 tt_prim_qspline: begin                         moveto( action, points[ 0 ].x.value, points[ 0 ].y.value );                         pa.x := points[ 0 ].x.value;                         pa.y := points[ 0 ].y.value;                         := 1 c.cpfx - 1 begin   // drawqspline called c.cpfx - 1 times                             pb.x := points[ ].x.value;                             pb.y := points[ ].y.value;                             pc.x := points[ + 1 ].x.value;                             pc.y := points[ + 1 ].y.value;                             if < c.cpfx - 1 begin                                 pc.x := ( pc.x + pb.x ) div 2;                                 pc.y := ( pc.y + pb.y ) div 2;                             end;                             j := 1 8 begin                                 f := j / 8;                                 lineto( action, round( ( pa.x - 2 * pb.x + pc.x ) * sqr( f ) + ( 2 * pb.x - 2 * pa.x ) * f + pa.x ),                                     round( ( pa.y - 2 * pb.y + pc.y ) * sqr( f ) + ( 2 * pb.y - 2 * pa.y ) * f + pa.y ) );                             end;                             pa := pc;                         end;                     end;             end;             // update last point.             points[ 0 ] := points[ c.cpfx ];         end;         moveto( action, points[ 0 ].x.value, points[ 0 ].y.value );         lineto( action, h.pfxstart.x.value, h.pfxstart.y.value );     until p >= longword( length( fbuffer ) ); end; 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -