The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Line cap (square)

These changes was commited to the Birdfont repository Mon, 11 May 2015 10:18:23 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 11 May 2015 10:18:23 +0000 (12:18 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 11 May 2015 10:18:23 +0000 (12:18 +0200)
commit fb52d7788451a6d80d1eefe1c2b301356e1187d9
tree 8ec5b29f5608c27091bb51b19838b04064c7a19a
parent d917592a17acc6192a5cbed1376308e32f2a84e0
Line cap (square)

libbirdfont/StrokeTool.vala
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -281,6 +281,29 @@ } return false; + } + + static void add_line_cap (Path path, Path stroke, + EditPointHandle last_handle, + EditPoint start, EditPoint end) { + + EditPoint n; + double stroke_width = path.stroke / 2; + + double y = sin (last_handle.angle - PI) * stroke_width; + double x = cos (last_handle.angle - PI) * stroke_width; + + n = stroke.add (start.x + x, start.y + y); + n.type = start.type; + n.get_right_handle ().type = start.type; + n.get_left_handle ().type = start.type; + n.convert_to_line (); + + n = stroke.add (end.x + x, end.y + y); + n.type = start.type; + n.get_right_handle ().type = start.type; + n.get_left_handle ().type = start.type; + n.convert_to_line (); } /** Create one stroke from the outline and counter stroke and close the @@ -291,6 +314,7 @@ * @param stroke for the counter path */ static Path merge_strokes (Path path, Path stroke, Path counter) { + Path merged; EditPoint last_counter, first; @@ -303,7 +327,13 @@ last_counter = new EditPoint (); first = new EditPoint (); + add_line_cap (path, merged, path.get_first_point ().get_right_handle (), + merged.get_last_point (), counter.get_first_point ()); + merged.append_path (counter); + + add_line_cap (path, merged, path.get_last_point ().get_left_handle (), + merged.get_last_point (), merged.get_first_point ()); merged.close (); merged.create_list ();