Skip to content

Commit

Permalink
Merge pull request #27 from jhps/measure-tool-xy
Browse files Browse the repository at this point in the history
Add X and Y distances to segments in measure tool, update docs.
  • Loading branch information
davelab6 committed Aug 27, 2012
2 parents 5e85b71 + 1f8641b commit 2369aee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 9 additions & 4 deletions fontforge/cvruler.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static int RulerTextIntersection(CharView *cv, unichar_t *ubuf, int i) {
real xoff = cv->ruler_intersections[cv->num_ruler_intersections-2].x - cv->ruler_intersections[1].x;
real yoff = cv->ruler_intersections[cv->num_ruler_intersections-2].y - cv->ruler_intersections[1].y;
real len = sqrt(xoff*xoff+yoff*yoff);
sprintf(buf,"First Edge to Last Edge: %f",len);
sprintf(buf,"First Edge to Last Edge: %f x %f length %f",fabs(xoff),fabs(yoff),len);
utf82u_strcpy(ubuf,buf);
return( 1 );
} else if ( cv->num_ruler_intersections>4 )
Expand All @@ -265,7 +265,7 @@ return( 0 );
real xoff = cv->ruler_intersections[i].x - cv->ruler_intersections[i-1].x;
real yoff = cv->ruler_intersections[i].y - cv->ruler_intersections[i-1].y;
real len = sqrt(xoff*xoff+yoff*yoff);
sprintf(buf,"[%d] (%f,%f) length %f",i,cv->ruler_intersections[i].x,cv->ruler_intersections[i].y, len);
sprintf(buf,"[%d] (%f,%f) %f x %f length %f",i,cv->ruler_intersections[i].x,cv->ruler_intersections[i].y,fabs(xoff),fabs(yoff),len);
}

utf82u_strcpy(ubuf,buf);
Expand Down Expand Up @@ -313,6 +313,10 @@ return( -1 );
return( 0 );
}

static int ReverseBasePointCompare(const BasePoint *l,const BasePoint *r) {
return( -BasePointCompare(l,r) );
}

/*
* Fill buffer with intersects on a line (from,to).
* return number found, buf fill the buffer only up to a max_intersections.
Expand Down Expand Up @@ -365,12 +369,13 @@ static int GetIntersections(CharView *cv,BasePoint from,BasePoint to,BasePoint *
}
}

all_intersections[total_intersections++] = to;
if ( total_intersections<max_intersections )
all_intersections[total_intersections++] = to;

qsort(all_intersections,
total_intersections > max_intersections ? max_intersections : total_intersections,
sizeof(all_intersections[0]),
BasePointCompare);
BasePointCompare(&from,&to)<=0 ? BasePointCompare : ReverseBasePointCompare );

return( total_intersections ); /* note that it could be greater than max */
}
Expand Down
5 changes: 4 additions & 1 deletion htdocs/charview.html
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,14 @@ <H3>
the mouse to the last point, the mouse's current location. The next lines in the pop-up
show information about points along the line that intersect splines, including the start and end
points of the line itself.
If there are more than two intersections then the x, y, and total distance
between the first and last intersections are shown before the point list.
<P>
[0] indicates the starting point of the measure line, and the (x-y) co-ordinates
of that point. Initially [1] is the end point; when it intersects with one spline then
[1] becomes the first intersection point and [2] becomes the end point, and so on.
The final number is the length of the section ending at that point; which is also shown
The co-ordinates are followed by the x and y distances and then
the final number is the length of the section ending at that point; which is also shown
directly on the canvas.
<P>
If you hold down the
Expand Down

0 comments on commit 2369aee

Please sign in to comment.