Commit 37d006d
clean up for version 0.1
Changed files (9)
modifiedsrc/ExportTool.valamodifiedsrc/Font.valamodifiedsrc/Glyph.valamodifiedsrc/MenuTab.valamodifiedsrc/OverView.valamodifiedsrc/Path.valamodifiedsrc/Preview.valamodifiedsrc/Supplement.valamodifiedsrc/Toolbox.vala
Diff
@@ -25,7 +25,6 @@ class ExportTool : Tool { base (n, "Export glyph to svg file", 'e', CTRL); select_action.connect((self) => {- print ("export_ttf_font:\n"); export_svg_font (); // Fixa: add export_glyph_to_svg (); as tool in toolbox });@@ -43,10 +42,12 @@ class ExportTool : Tool { public static void export_all () { Font font = Supplement.get_current_font (); - if (font.get_ttf_export ()) {- export_ttf_font ();+ if (Supplement.experimental) {+ if (font.get_ttf_export ()) {+ export_ttf_font ();+ } }-+ if (font.get_svg_export ()) { export_svg_font (); }@@ -696,6 +696,9 @@ class Font : GLib.Object { otf_font = false; + font_file = "";+ name = "typeface";+ while (glyph_names.length () > 0) { glyph_names.remove_link (glyph_names.first ()); }@@ -703,14 +706,16 @@ class Font : GLib.Object { glyph_cache.remove_all (); unassigned_glyphs.remove_all (); - font_file = path;- if (path.has_suffix (".ffi")) { loaded = parse_file (path);+ font_file = path; } - if (path.has_suffix (".ttf")) {- loaded = parse_otf_file (path);+ if (Supplement.experimental) {+ if (path.has_suffix (".ttf")) {+ loaded = parse_otf_file (path);+ font_file = path;+ } } return loaded;@@ -785,17 +790,12 @@ class Font : GLib.Object { return; } - // del: print (@"added name: $(g.name)\n");- add_glyph_collection ((!) gc); } else if (gcl == null) { gc = new GlyphCollection (g); add_glyph_collection ((!) gc); } else { stderr.printf (@"Glyph collection does already have an entry for $(g.get_name ()) char $((uint64) g.unichar_code).\n");- //gc = new GlyphCollection (g);- //g.name = @"($(++next_unindexed))";- //add_glyph_collection ((!) gc); } // take xheight from appropriate lower case letter@@ -296,7 +296,6 @@ class Glyph : FontDisplay { } public void add_help_lines () {- remove_lines (); double bgt = Supplement.get_current_font ().top_limit;@@ -141,10 +141,17 @@ class MenuTab : FontDisplay { <div class="content"> <form>+""");++if (Supplement.experimental) {+ c.append (""" <h3>Formats</h3> <input class="checkbox" type="checkbox" id="svg" checked="checked" onchange="update_export_settings ();"/> SVG<br /> <input class="checkbox" type="checkbox" id="ttf" checked="checked" onchange="update_export_settings ();"/> TTF<br />+ """);+} +c.append (""" <h3>Name</h3> <input class="text" type="text" id="fontname" value=""" + "\"" + f.get_name () + "\"" + """ onchange="update_export_settings ();"/><br /> @@ -461,7 +461,9 @@ class OverView : FontDisplay { cr.fill (); cr.restore (); - scrollbar.draw (cr, allocation);+ if (Supplement.experimental) {+ scrollbar.draw (cr, allocation);+ } n_items = ((allocation.width - 15) / nail_width); rows = (allocation.height / nail_height);@@ -976,7 +978,9 @@ class OverView : FontDisplay { public override void button_press (EventButton e) { if (e.x > allocation.width - 10) {- scrollbar.button_press (e);+ if (Supplement.experimental) {+ scrollbar.button_press (e);+ } } else { selection_click (e); }@@ -1567,16 +1567,16 @@ class Path { } public static PathList merge (Path p0, Path p1) {- bool err;+ bool done; PathList path_list; - err = try_merge (p1.copy(), p0.copy(), out path_list);+ done = try_merge (p1.copy(), p0.copy(), out path_list); - if (err) {- err = try_merge (p0.copy(), p1.copy(), out path_list);+ if (!done) {+ done = try_merge (p0.copy(), p1.copy(), out path_list); } - if (err) {+ if (!done) { warning ("failed to merge paths"); } @@ -1589,6 +1589,8 @@ class Path { EditPoint ex; EditPoint ix;+ EditPoint prev;+ uint offset_i = 0; uint offset_j; uint len_i;@@ -1601,7 +1603,7 @@ class Path { path_list = new PathList (); if (p0 == p1) {- return true;+ return false; } // add editpoints points on intersections @@ -1627,31 +1629,43 @@ class Path { } if (il.points.length () == 0) {- return true;+ return false; } // begin outside intersection ex = p0.points.first ().data;+ prev = p0.points.first ().data; for (i = 0; i < p0.points.length (); i++) {- ex = ex.get_next ().data;+ ex = prev.get_next ().data; - if (!p1.is_over_coordinate (ex.x, ex.y) && !il.has_edit_point (ex)) {- p0.set_new_start (ex); + if (i != 0 && !p1.is_over_coordinate (ex.x, ex.y) && !p1.is_over_coordinate (prev.x, prev.y) && !il.has_edit_point (prev) && !il.has_edit_point (ex)) {+ p0.set_new_start (ex);+ break; }+ + prev = ex; } if (i == p0.points.length ()) { warning ("no point outside path."); } + print (@"il.points.length (): $(il.points.length ())\n");++ //path_list.paths.append (p0);+ //path_list.paths.append (p1);+ //return false;+ // create a new path - np = create_merged_path (il, p0, p1);+ if (!create_merged_path (il, p0, p1, out np)) {+ return false;+ } path_list.paths.append (np); if (!np.is_clockwise ()) { warning ("Outline is counter clockwise after merge");- return true;+ return false; } // find counter path if we have more intersections@@ -1659,21 +1673,23 @@ class Path { ex = p0.points.first ().data; p0.set_new_start (il.points.first ().data.editpoint_a); - np_counter = create_merged_path (il, p0, p1);+ if (!create_merged_path (il, p0, p1, out np_counter)) {+ warning ("Failed to merge counter");+ } path_list.paths.append (np_counter); if (np_counter.is_clockwise ()) { warning ("Counter is clockwise after merge");- return true;+ return false; } } - return false;+ return true; } - private static Path create_merged_path (IntersectionList il, Path p0, Path p1) {+ private static bool create_merged_path (IntersectionList il, Path p0, Path p1, out Path new_path) { EditPoint ex; EditPoint ix; uint offset_i = 0;@@ -1697,10 +1713,11 @@ class Path { } // add new point for path a- np.add_point (ex);- if (np.has_edit_point (ix)) {+ if (np.has_edit_point (ex)) { // SPLIT+ warning ("Merged path need split"); } else {+ np.add_point (ex); ex.recalculate_linear_handles (); } @@ -1734,10 +1751,11 @@ class Path { // add if (np.has_edit_point (ix)) { // SPLIT+ warning ("Merged path need split"); } else {+ np.add_point (ix); ix.recalculate_linear_handles (); }- np.add_point (ix); if (il.has_edit_point (ix)) { s = (!) il.get_intersection (ix);@@ -1755,7 +1773,8 @@ class Path { if (j == p0.points.length ()) { np.close ();- return np;+ new_path = np;+ return true; } // skip to next intersection@@ -1769,7 +1788,8 @@ class Path { } if (k == p0.points.length ()) {- return np;+ new_path = np;+ return true; } offset_i = 0;@@ -1777,7 +1797,9 @@ class Path { } } - return np; + new_path = np;+ + return true; } } @@ -48,8 +48,6 @@ class Preview : FontDisplay { ExportTool.generate_html_document ((!)file.get_path (), font); } - print (@"uri $(path_to_uri ((!)file.get_path ()))\n");- return path_to_uri ((!)file.get_path ()); } }@@ -21,10 +21,11 @@ namespace Supplement { class Supplement { + public static Argument args; + public static bool experimental; + static Font current_font; - public static Argument args; - public static Font get_current_font () { return current_font; } @@ -102,6 +103,8 @@ class Supplement { Process.exit (0); } + experimental = args.has_argument ("--test"); + Preferences preferences = new Preferences (); preferences.load (); @@ -132,6 +135,8 @@ class Supplement { if (args.get_file () != "") { current_font.load (args.get_file ()); MainWindow.get_toolbox ().select_tool_by_name ("available_characters"); + } else { + MainWindow.get_tab_bar ().select_tab_name ("Menu"); } return false; @@ -98,16 +98,6 @@ class Toolbox : DrawingArea { draw_tool_modifiers.add_tool (new_point); - Tool corner_tool = new Tool ("corner", "Edit corner", 'e');- corner_tool.select_action.connect((self) => {- select_draw_tool ();- pen_tool.edit_active_corner = true;- });- corner_tool.deselect_action.connect((self) => {- pen_tool.edit_active_corner = false;- });- draw_tool_modifiers.add_tool (corner_tool);- Tool insert_point_on_path = new Tool ("insert_point_on_path", "Add new point on path", 'n'); insert_point_on_path.select_action.connect((self) => { select_draw_tool ();@@ -115,46 +105,14 @@ class Toolbox : DrawingArea { }); draw_tool_modifiers.add_tool (insert_point_on_path); - Tool new_point_on_path = new Tool ("new_point_on_path", "Begin new path from point on path", 'n');- new_point_on_path.select_action.connect((self) => {- select_draw_tool ();- pen_tool.begin_from_new_point_on_path ();- });- draw_tool_modifiers.add_tool (new_point_on_path);-- Tool move_point_on_path = new Tool ("move_point", "Move edit point", 'm');- move_point_on_path.select_action.connect((self) => {- select_draw_tool ();- pen_tool.move_point_on_path = true;- });- corner_tool.deselect_action.connect((self) => {- pen_tool.move_point_on_path = false;- });- draw_tool_modifiers.add_tool (move_point_on_path); -- Tool close_paths_tool = new Tool ("close_paths", "Open or close paths", 'c');- close_paths_tool.select_action.connect((self) => {- Glyph g = MainWindow.get_current_glyph ();- - select_draw_tool ();- - // Set direction for inside or outside- cut_tool.force_direction ();- - if (!g.close_path ()) {- g.open_path ();- }- - TimeoutSource anim = new TimeoutSource (300);- anim.set_callback(() => {- select_tool (new_point);- return false;+ if (Supplement.experimental) {+ Tool new_point_on_path = new Tool ("new_point_on_path", "Begin new path from point on path", 'n');+ new_point_on_path.select_action.connect((self) => {+ select_draw_tool ();+ pen_tool.begin_from_new_point_on_path (); });- - anim.attach (null);- - });- draw_tool_modifiers.add_tool (close_paths_tool); + draw_tool_modifiers.add_tool (new_point_on_path); + } Tool tie_editpoint_tool = new Tool ("tie_point", "Tie curve handles for selected edit point", 'w'); tie_editpoint_tool.select_action.connect((self) => {@@ -170,16 +128,7 @@ class Toolbox : DrawingArea { ep.process_tied_handle (); } - ep.set_tie_handle (tie);- - TimeoutSource anim = new TimeoutSource (300);- anim.set_callback(() => {- select_tool (corner_tool);- return false;- });- - anim.attach (null);- + ep.set_tie_handle (tie); }); draw_tool_modifiers.add_tool (tie_editpoint_tool); @@ -197,8 +146,10 @@ class Toolbox : DrawingArea { draw_tool_modifiers.add_tool (erase_tool); // path tools- Tool union_paths_tool = new MergeTool ("union_paths");- path_tool_modifiers.add_tool (union_paths_tool);+ if (Supplement.experimental) {+ Tool union_paths_tool = new MergeTool ("union_paths");+ path_tool_modifiers.add_tool (union_paths_tool);+ } Tool reverse_path_tool = new Tool ("reverse_path", "Create counter from outline", 'r'); reverse_path_tool.select_action.connect((self) => {@@ -578,7 +529,10 @@ class Toolbox : DrawingArea { add_expander (grid); add_expander (view_tools); - add_expander (background_tools);+ if (Supplement.experimental) {+ add_expander (background_tools);+ }+ // Fixa: add_expander (trace); add_expander (test_tools);@@ -653,6 +607,7 @@ class Toolbox : DrawingArea { idle.set_callback (() => { new_point.set_selected (true); pen_tool.set_selected (true);+ select_draw_tool (); if (glyph_canvas.get_current_glyph ().get_show_help_lines ()) { help_lines.set_selected (true);@@ -701,10 +656,6 @@ class Toolbox : DrawingArea { } private void select_draw_tool () {- if (current_tool is PenTool || current_tool is CutTool) {- return;- }- select_tool_by_name ("pen_tool"); }