SVGPath-1.0: Parsing the path command from SVG

MaintainerTillmann Vogt <>



parsing the SVG path command, see :



pathFromString :: String -> IO [PathCommand]Source

convert a SVG path string into alist of commands

data PathCommand Source


M_abs Tup 
M_rel Tup

establish a new current point (with absolute coords or rel. to the current point)


Close current subpath by drawing a straight line from current point to current subpath's initial point

L_abs Tup 
L_rel Tup

a line from the current point to Tup which becomes the new current point

H_abs X 
H_rel X

a horizontal line from the current point (cpx, cpy) to (x, cpy)

V_abs Y 
V_rel Y

a vertical line from the current point (cpx, cpy) to (cpx, y)

C_abs (X1, Y1, X2, Y2, X, Y)

Draws a cubic Bzier curve from the current point to (x,y) using (x1,y1) as the ^control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve.

C_rel (X1, Y1, X2, Y2, X, Y) 
S_abs (X2, Y2, X, Y)

Draws a cubic Bzier curve from the current point to (x,y). The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not an C, c, S or s, assume the first control point is coincident with the current point.) (x2,y2) is the second control point (i.e., the control point at the end of the curve).

S_rel (X2, Y2, X, Y) 
Q_abs (X1, Y1, X, Y)

a quadr. Bzier curve from the curr. point to (x,y) using (x1,y1) as the control point

Q_rel (X1, Y1, X, Y)

nearly the same as cubic, but with one point less

T_abs Tup 
T_rel Tup

T_Abs = Shorthand/smooth quadratic Bezier curveto


A = elliptic arc


A = elliptic arc (not used)


commandsToPoints :: [PathCommand] -> F2 -> [[F2]]Source

convert path-commands to outline points

bSubCurve :: Bool -> (X, Y) -> [F2] -> [F2]Source

bSubcurve uses bezier subdivision. (inspired by Hersch, Font Rasterization: the State of the Art (freely available)) It divides an arc into two arcs recursively until the arc is either completely between two vertical raster lines or completely between two horizontal raster lines or the line is at most 1 pixel long. This function computes outline points (tex==False) as well as border points for rasterisation (tex==True) by using an x-, y-resoultion raster. dx, dy is the width and height of a pixel of this raster.