The Birdfont Source Code
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
Line cap (square)
--- 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 ();