lff definition

borneq edited this page Jan 21, 2012 · 6 revisions

LibreCAD Font File explanation.

The header of file is self-documented

below a explanation of a glyph definition:

[0041] A

line 1 => utf-8 code + letter

line 2 & 3 =>sequence like polyline vertex with ";" separating vertex and "," separating x,y coords. One polyline definition in each line of text

[0066] f

line 2 =>sequence like polyline vertex with ";" seperating vertex and "," separating x,y coords, if there is a third field prefixed with "A" this field is a polyline bulge (the tangent of 1/4 of the arc angle)

[00C1] Á

line 2 =>copy defined char 0041 "A" as a nested block

Notes about arc bulge: The bulge is the tangent of 1/4 of the arc angle. If bulge is positive the arc included angle is counter-clockwise.

For code to calculate center, radius and included angle you can see the function, in file src/lib/engine/rs_polyline.cpp:

RS_Entity* RS_Polyline::createVertex(const RS_Vector& v, double bulge, bool prepend)

p.e. the formula to calculate the radius is:

A = arctangent(B)*4

R = absolute(D / (sin(A/2)*2) )


  • B is bulge

  • D is distance from start to end point

  • R is the calculated radius

Another formula to calculate the radius:

S = B*d

R = (SS + dd) / (2*S)


  • B is bulge

  • S is the calculated sagitta

  • d is half chord (half of distance from start to end point)

  • R is the calculated radius

Determining direction:

  • In: LastPoint and PrevPoint

  • Out: points starting and ending arc

    if (B>=0) { startPoint = PrevPoint; endPoint = LastPoint; }
    else { startPoint = LastPoint; endPoint = PrevPoint; }

Calculate center of circle of arc:

Point Middle = (PrevPoint + LastPoint) /2 
z - distance from Middle to Center
z = sqrt(sqr(R)-sqr(d)); //d = D/2
Center is in distance z from Middle in direction perpendicular to line between startPoint and endPoint
center.X = middle.X - (endPoint.y-startPoint.y)/d*z;
center.Y = middle.Y + (endPoint.x-startPoint.x)/d*z;
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.