lff definition - Rallaz/LibreCAD GitHub Wiki

LibreCAD Font File explanation.

The header of file is self-documented

below a explanation of a glyph definition:

[0041] A
0.0000,0.0000;3.0000,9.0000;6.0000,9.000
1.0800,2.5500;4.7300,2.5500

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
1,0;1,7.5;2.5,9,A-0.414214;3,9
0,6;3,6

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] Á
C0041
2.000000,9.0000,4.0000,10.0000

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) )

where

  • 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)

where

  • 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;