The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Merge

These changes was commited to the Birdfont repository Thu, 13 Aug 2015 14:44:16 +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>
Thu, 13 Aug 2015 14:44:16 +0000 (16:44 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 13 Aug 2015 14:44:16 +0000 (16:44 +0200)
commit 7cb1e1d94d7c534c832788fa9410d7d720a3ec3d
tree c42817d1f1336f24f071874620fc07feac24af17
parent 51964e15bf43d789f751dbac11ccaee61d079245
Merge

libbirdfont/StrokeTool.vala
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -122,12 +122,13 @@ p1 = o.paths.get (i); p2 = o.paths.get (j); - if (i == j) { - continue; + if (i == j) { // merge self intersections + p2 = new Path (); + r = merge_selected (p1, p2, false); + } else { + r = merge_selected (p1, p2); } - - r = merge_selected (p1, p2); - + // FIXME: delete foreach (Path p in r.paths) { ((!) BirdFont.get_current_font ().get_glyph_by_name ("c")).add_path (p.copy ()); @@ -235,7 +236,9 @@ } } - public static PathList merge_selected (Path path1, Path path2) { + public static PathList merge_selected (Path path1, Path path2, + bool check_boundaries = true) { + PathList flat = new PathList (); PathList o = new PathList (); PathList pl = new PathList (); @@ -243,11 +246,13 @@ pl.add (path1); pl.add (path2); - - if (!path1.boundaries_intersecting (path2)) { - return r; + + if (check_boundaries) { + if (!path1.boundaries_intersecting (path2)) { + return r; + } } - + foreach (Path p in pl.paths) { if (p.stroke == 0) { o.add (p); @@ -400,29 +405,48 @@ return_val_if_fail (parts.paths.size >= 2, r); - p1 = parts.paths.get (0); - p2 = parts.paths.get (1); + //p1 = parts.paths.get (0); + //p2 = parts.paths.get (1); - // FIXME: PUT BACK - return r; + parts = merge_all (parts); - r = merge_paths_with_curves (p1, p2); + // FIXME: remove split points + + foreach (Path p in parts.paths) + ((!) BirdFont.get_current_font ().get_glyph_by_name ("g")).add_path (p); - for (int i = 2; i < parts.paths.size; i++) { - Path other_part = parts.paths.get (i); - r.add (other_part); - } + return parts; + } + + static PathList merge_all (PathList pl) { + PathList np = new PathList (); - print (@"Result $(r.paths.size)\n"); - if (r.paths.size > 0) { - o.paths.remove (p1); - o.paths.remove (p2); - o.append (r); + np.append (pl); + + for (int i = 0; i < np.paths.size; i++) { + for (int j = 0; j < np.paths.size; j++) { + PathList merged_paths; + + if (i == j) { + continue; + } + + Path p1 = np.paths.get (i); + Path p2 = np.paths.get (j); + + merged_paths = merge_paths_with_curves (p1, p2); + + if (merged_paths.paths.size > 0) { + print (@"result: $(merged_paths.paths.size)\n"); + np.remove (p1); + np.remove (p2); + np.append (merged_paths); + return merge_all (np); + } + } } - - // FIXME: remove split points - return r; + return np; } static PathList remove_self_intersections (Path original) { @@ -598,7 +622,8 @@ merged.get_first_point ().color = Color.green (); merged.get_last_point ().color = Color.brown (); - // return parts; // FIXME: DELETE + + merged.reverse (); merged = new Path ();