The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – RSS feed

Paste color SVG files

These changes was commited to the Birdfont repository Fri, 24 Jun 2016 17:18:10 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
[Fri, 24 Jun 2016 17:18:10 +0000]

Updated Files

libbirdfont/BezierTool.vala
libbirdfont/ClipTool.vala
libbirdfont/Glyph.vala
libbirdfont/MenuTab.vala
libbirdfont/MoveTool.vala
libbirdfont/PenTool.vala
libbirdfont/ResizeTool.vala
libbirdfont/StrokeTool.vala
libbirdfont/SvgParser.vala
libsvgbird/SvgFile.vala
--- a/libbirdfont/BezierTool.vala +++ b/libbirdfont/BezierTool.vala @@ -175,7 +175,7 @@ current_path.recalculate_linear_handles_for_point (current_point); set_point_type (); g.clear_active_paths (); - g.add_active_path (null, current_path); + g.add_active_path (current_path); GlyphCanvas.redraw (); state = MOVE_POINT; } else { @@ -282,7 +282,7 @@ current_path.recalculate_linear_handles_for_point (current_point); set_point_type (); g.clear_active_paths (); - g.add_active_path (null, current_path); + g.add_active_path (current_path); GlyphCanvas.redraw (); state = MOVE_POINT;
--- a/libbirdfont/ClipTool.vala +++ b/libbirdfont/ClipTool.vala @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 2014 Johan Mattsson + Copyright (C) 2012 2014 2016 Johan Mattsson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as @@ -146,7 +146,9 @@ if (bf_clipboard_data) { import_birdfont_clipboard (data, paste_guide_lines, false); } else if (data != "") { - SvgParser.import_svg_data (data, SvgFormat.INKSCAPE); + //SvgParser.import_svg_data (data, SvgFormat.INKSCAPE); + print (@"$data\n\n"); + SvgParser.import_svg_color_data (data); } ((!)destination).update_view (); @@ -423,7 +425,7 @@ foreach (Path p in glyph.get_visible_paths ()) { PenTool.clear_directions (); destination.add_path (p); - destination.add_active_path (null, p); + destination.add_active_path (p); } if (paste_guide_lines) { @@ -450,7 +452,7 @@ if (path.points.size > 0) { PenTool.clear_directions (); glyph.add_path (path); - glyph.add_active_path (null, path); + glyph.add_active_path (path); path.update_region_boundaries (); }
--- a/libbirdfont/Glyph.vala +++ b/libbirdfont/Glyph.vala @@ -275,36 +275,25 @@ active_paths.clear (); } - public void add_active_path (Layer? group, Path? p) { - if (p != null) { - PathObject path = new PathObject.for_path ((!) p); - add_active_object (group, path); - } else { - add_active_object (group, null); - } + public void add_active_path (Path p) { + PathObject path = new PathObject.for_path ((!) p); + add_active_object (path); } - // FIXME: delete group - public void add_active_object (Layer? group, SvgBird.Object? o) { - SvgBird.Object object; - - if (o != null) { - object = (!) o; - - if (!active_paths_contains (object)) { - active_paths.add (object); + public void add_active_object (SvgBird.Object object) { + if (!active_paths_contains (object)) { + active_paths.add (object); + } + + if (object is PathObject) { + PathObject path = (PathObject) object; + if (Toolbox.get_move_tool ().is_selected ()) { + if (path.get_path ().stroke > 0) { + Toolbox.set_object_stroke (path.get_path ().stroke); + } } - if (object is PathObject) { - PathObject path = (PathObject) object; - if (Toolbox.get_move_tool ().is_selected ()) { - if (path.get_path ().stroke > 0) { - Toolbox.set_object_stroke (path.get_path ().stroke); - } - } - - PenTool.active_path = path.get_path (); - } + PenTool.active_path = path.get_path (); } } @@ -866,7 +855,7 @@ path.create_list (); PathObject object = new PathObject.for_path (path); - add_active_object (null, object); + add_active_object (object); } if (remaining_points.paths.size > 0) { @@ -981,7 +970,7 @@ public void set_active_path (Path p) { p.reopen (); clear_active_paths (); - add_active_object (null, new PathObject.for_path (p)); + add_active_object (new PathObject.for_path (p)); } /** Move view port centrum to this coordinate. */ @@ -1875,7 +1864,7 @@ clear_active_paths (); foreach (SvgBird.Object p in g.active_paths) { - add_active_object (null, p); + add_active_object (p); } redraw_area (0, 0, allocation.width, allocation.height);
--- a/libbirdfont/MenuTab.vala +++ b/libbirdfont/MenuTab.vala @@ -654,7 +654,7 @@ // selected segments if (paths.size == 0) { foreach (Path p in g.get_active_paths ()) { - g.add_active_path (null, p); + g.add_active_path (p); } foreach (Path p in g.get_active_paths ()) { @@ -674,7 +674,7 @@ foreach (Path p in paths) { g.add_path (p); - g.add_active_path (null, p); + g.add_active_path (p); } g.active_paths.clear ();
--- a/libbirdfont/MoveTool.vala +++ b/libbirdfont/MoveTool.vala @@ -202,7 +202,7 @@ if (selected && KeyBindings.has_shift ()) { glyph.active_paths.remove (object); } else { - glyph.add_active_object (null, object); + glyph.add_active_object (object); } } else if (!KeyBindings.has_shift ()) { glyph.clear_active_paths (); @@ -238,7 +238,7 @@ foreach (SvgBird.Object p in glyph.get_objects_in_current_layer ()) { if (p.xmin > x1 && p.xmax < x2 && p.ymin < y1 && p.ymax > y2) { if (!p.is_empty ()) { - glyph.add_active_object (null, p); + glyph.add_active_object (p); } } } @@ -471,7 +471,7 @@ g.clear_active_paths (); foreach (SvgBird.Object p in g.get_objects_in_current_layer ()) { if (!p.is_empty ()) { - g.add_active_object (null, p); + g.add_active_object (p); } }
--- a/libbirdfont/PenTool.vala +++ b/libbirdfont/PenTool.vala @@ -1231,7 +1231,7 @@ glyph.clear_active_paths (); PathObject path = new PathObject.for_path (active_path); - glyph.add_active_object (null, path); + glyph.add_active_object (path); DrawingTools.update_stroke_settings (); @@ -1414,7 +1414,7 @@ PathObject merged_path = new PathObject.for_path (merge); if (is_close_to_point (merge.points.get (merge.points.size - 1), px, py)) { - glyph.add_active_object (null, merged_path); + glyph.add_active_object (merged_path); active_path = merge; merge.reopen (); glyph.open_path (); @@ -1422,7 +1422,7 @@ } if (is_close_to_point (merge.points.get (0), px, py)) { - glyph.add_active_object (null, merged_path); + glyph.add_active_object (merged_path); active_path = merge; clear_directions (); merge.reopen (); @@ -1460,7 +1460,7 @@ glyph.clear_active_paths (); PathObject closed_path = new PathObject.for_path (path); - glyph.add_active_object (null, closed_path); + glyph.add_active_object (closed_path); if (direction_changed) { path.reverse (); @@ -1504,7 +1504,7 @@ glyph.delete_path (path); glyph.delete_path (merge); glyph.clear_active_paths (); - glyph.add_active_object (null, union_path); + glyph.add_active_object (union_path); union.reopen (); union.create_list (); @@ -1794,7 +1794,7 @@ active_path = new_point.path; glyph.clear_active_paths (); - glyph.add_active_object (null, object); + glyph.add_active_object (object); move_selected = true; } @@ -1844,7 +1844,7 @@ np.line_cap = StrokeTool.line_cap; path = new PathObject.for_path (np); - g.add_active_object (null, path); + g.add_active_object (path); active_path = np; selected_path = np; @@ -1867,7 +1867,7 @@ } path = new PathObject.for_path (np); - g.add_active_object (null, path); + g.add_active_object (path); PenTool.active_path = np; PenTool.selected_path = np; @@ -1875,7 +1875,7 @@ g.clear_active_paths (); path = new PathObject.for_path (np); - g.add_active_object (null, path); + g.add_active_object (path); active_path = np; selected_path = np; @@ -2086,7 +2086,7 @@ active_path = p.path; PathObject path = new PathObject.for_path (active_path); - g.add_active_object (null, path); + g.add_active_object (path); } public static void add_selected_point (EditPoint p, Path path) {
--- a/libbirdfont/ResizeTool.vala +++ b/libbirdfont/ResizeTool.vala @@ -369,7 +369,7 @@ glyph.clear_active_paths (); foreach (SvgBird.Object path in glyph.get_visible_objects ()) { - glyph.add_active_object (null, path); + glyph.add_active_object (path); } } @@ -544,7 +544,7 @@ glyph.clear_active_paths (); foreach (SvgBird.Object path in glyph.get_visible_objects ()) { - glyph.add_active_object (null, path); + glyph.add_active_object (path); } }
--- a/libbirdfont/StrokeTool.vala +++ b/libbirdfont/StrokeTool.vala @@ -232,7 +232,7 @@ foreach (Path p in new_paths.paths) { PathObject path = new PathObject.for_path (p); g.add_object (path); - g.add_active_object (null, path); + g.add_active_object (path); } PenTool.update_orientation ();
--- a/libbirdfont/SvgParser.vala +++ b/libbirdfont/SvgParser.vala @@ -62,9 +62,26 @@ fc.add_extension ("svg"); MainWindow.file_chooser (t_("Import"), fc, FileChooser.LOAD); } + + public static void import_svg_color_data (string svg_data) { + Glyph glyph = MainWindow.get_current_glyph (); + EmbeddedSvg drawing = SvgParser.parse_embedded_svg_data (svg_data); + glyph.add_object (drawing); + + Font font = BirdFont.get_current_font (); + drawing.x = glyph.left_limit; + drawing.y = font.top_position - font.base_line; + + drawing.update_boundaries_for_object (); + + glyph.clear_active_paths (); + glyph.add_active_object (drawing); + } + public static void import_color_svg (Glyph glyph, string path) { - EmbeddedSvg drawing = SvgParser.parse_embedded_svg_file (path); + EmbeddedSvg drawing = SvgParser.parse_embedded_svg_data (path); + glyph.add_object (drawing); drawing.update_boundaries_for_object (); @@ -153,7 +170,7 @@ foreach (Path p in path_list.paths) { PathObject path = new PathObject.for_path (p); glyph.add_object (path); - glyph.add_active_object (null, path); // FIXME: groups + glyph.add_active_object (path); // FIXME: groups path.update_boundaries_for_object (); }
--- a/libsvgbird/SvgFile.vala +++ b/libsvgbird/SvgFile.vala @@ -692,6 +692,8 @@ get_bezier_points (data, out bezier_points, out points_size, true); // all instructions are padded + + // FIXME: Inscape and Illustrator discrepancies for (int i = 0; i < points_size; i++) { // FIXME: add more types