Commit 439500a
remove some dead code
Changed files (12)
modifiedsrc/ExportTool.valamodifiedsrc/Font.valamodifiedsrc/Glyph.valamodifiedsrc/IntersectionList.valamodifiedsrc/OpenFontFormatWriter.valamodifiedsrc/Path.valamodifiedsrc/PenTool.valamodifiedsrc/Preview.valamodifiedsrc/Scrollbar.valamodifiedsrc/Svg.valamodifiedsrc/TestCases.valamodifiedsrc/Tool.vala
Diff
@@ -183,13 +183,15 @@ class ExportTool : Tool { return (!) prefered_browser; } - public static void generate_html_document (string html_file, Font font) throws Error {+ public static void generate_html_document (string html_file, Font font) { File file = File.new_for_path (html_file); DataOutputStream os = new DataOutputStream (file.create(FileCreateFlags.REPLACE_DESTINATION)); string name = font.get_name (); - os.put_string (+ try {++os.put_string ( """<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>@@ -337,6 +339,9 @@ os.put_string (""" </html> """); + } catch (GLib.Error e) {+ warning (e.message);+ } } public static bool export_ttf_font () {@@ -81,16 +81,6 @@ class Font : GLib.Object { modified = true; } - public string get_export_dir () - requires (font_file != null) - {- if (export_dir == null) {- return ((!) font_file).substring (0, ((!) font_file).last_index_of ("/") - 1);- }- - return (!) export_dir;- }- public bool get_ttf_export () { return ttf_export; }@@ -172,28 +162,6 @@ class Font : GLib.Object { return File.new_for_path (p); } - bool is_valid_thumbnail (Glyph? g) {- Glyph glyph;- double x1, x2, y1, y2;-- if (g == null) {- return false;- }- - glyph = (!) g;- - glyph.boundries (out x1, out y1, out x2, out y2);- - if (x1 < -120) return false;- if (x2 > 120) return false;- if (y1 < -76) return false;- if (y2 > 76) return false;- - if (x1 == 0 && x2 == 0 && y1 == 0 && y2 == 0) return false;- - return true;- }- public double get_height () { double r = base_line - top_position; return (r > 0) ? r : -r;@@ -1094,52 +1094,6 @@ class Glyph : FontDisplay { } } - public Line get_left_line () {- foreach (var line in horizontal_help_lines) {- if (line.get_label () == "left") {- return line;- }- }- - warn_if_reached ();- return new Line ();- } -- public Line get_right_line () {- foreach (var line in horizontal_help_lines) {- if (line.get_label () == "right") {- return line;- }- }- - warn_if_reached ();- return new Line ();- } -- /** lsb */- public double get_left_marker () {- foreach (var line in vertical_help_lines) {- if (line.get_label () == "left") {- return line.get_coordinate ();- }- }- - warn_if_reached ();- return 0;- } -- /** rsb */- public double get_right_marker () {- foreach (var line in vertical_help_lines) {- if (line.get_label () == "right") {- return line.get_coordinate ();- }- }- - warn_if_reached ();- return 0;- }- public Line get_line (string name) { foreach (Line line in vertical_help_lines) { if (likely (line.get_label () == name)) {@@ -1417,9 +1371,6 @@ class Glyph : FontDisplay { this.allocation = allocation; - ImageSurface ims = new ImageSurface (Format.ARGB32, allocation.width, allocation.height);- Context cms = new Context (ims);- ImageSurface ps = new ImageSurface (Format.ARGB32, allocation.width, allocation.height); Context cmp = new Context (ps); @@ -1691,6 +1642,10 @@ class Glyph : FontDisplay { /** Merge selected paths. */ public void merge_all () {+ bool merged = false;+ bool m = false;+ + store_undo_state (); delete_invisible_paths (); if (active_paths.length () < 2) {@@ -1698,7 +1653,6 @@ class Glyph : FontDisplay { } foreach (Path p0 in active_paths) {- // while (merge_path (p0)); merge_path (p0); } @@ -184,7 +184,6 @@ class IntersectionList { IntersectionList il = new IntersectionList (); double mind = double.MAX; ;- double distance = double.MAX; Path.all_of (a0, a1, (ax, ay, at) => { if (at == 0 || at == 1) {@@ -207,18 +206,6 @@ class IntersectionList { return il; }-- bool probably_intersecting (EditPoint a0, EditPoint a1, EditPoint b0, EditPoint b1) {- if (has_intersection (a0.x, a1.x, b0.x, b1.x) && has_intersection (a0.y, a1.y, b0.y, b1.y)) {- return true;- } -- if (has_intersection (a0.x, a1.x, b0.x, b1.x) && has_intersection (a0.y, a1.y, b0.y, b1.y)) {- return true;- } - - return false;- } /** return true if ranges does overlap */ bool has_intersection (double a0, double a1, double b0, double b1) {@@ -727,8 +727,6 @@ class GlyfTable : Table { double total_width = 0; int non_zero_glyphs = 0; - - int64 next_index = -1; public GlyfTable (LocaTable l) { id = "glyf"; @@ -737,25 +735,6 @@ class GlyfTable : Table { glyphs = new List<Glyph> (); } - public double get_xheight () { - return get_capheight (); // FIXME - } - - public double get_capheight () { - double x1, x2, y1, y2; - Font f = OpenFontFormatWriter.get_current_font (); - double max = double.MIN; - - foreach (Glyph g in glyphs) { - g.boundries (out x1, out y1, out x2, out y2); - if (y2 > max) { - max = y2; - } - } - - return max - f.base_line; - } - public int get_gid (string name) { int i = 0; foreach (Glyph g in glyphs) { @@ -835,13 +814,6 @@ class GlyfTable : Table { } public new void parse (FontData dis, CmapTable cmap_table, LocaTable loca, HmtxTable hmtx_table, HeadTable head_table, PostTable post_table, KernTable kern_table) throws GLib.Error { - printd (@"loca.size: $(loca.size)\n"); - - Glyph glyph; - unowned List<int> ind; - int i; - - // read_lock.lock (); this.cmap_table = cmap_table; this.post_table = post_table; this.loca_table = loca; @@ -849,8 +821,6 @@ class GlyfTable : Table { this.head_table = head_table; this.kern_table = kern_table; this.dis = dis; - - // post_table.print_all (); } Glyph parse_index (int index, FontData dis, LocaTable loca, HmtxTable hmtx_table, HeadTable head_table, PostTable post_table) throws GLib.Error { @@ -914,8 +884,6 @@ class GlyfTable : Table { F2Dot14 scale01; F2Dot14 scale10; - - uint16 num_instructions; Glyph glyph, linked_glyph; List<int> x = new List<int> (); @@ -2078,8 +2046,6 @@ class CmapTable : Table { CmapSubtableWindowsUnicode cmap = new CmapSubtableWindowsUnicode (); uint16 n_encoding_tables; uint32 subtable_offset = 0; - - uint16 glyph_indice = 0; n_encoding_tables = 1; @@ -2487,7 +2453,6 @@ class HmtxTable : Table { public void process () { FontData fd = new FontData (); - Font font = OpenFontFormatWriter.get_current_font (); int16 advance; int16 extent; @@ -4747,15 +4712,6 @@ class DirectoryTable : Table { return true; } - public new string get_id () { - warning ("Don't write id for table directory."); - return "Directory table"; // Table id should be ignored for directory table, none the less it has one declared here. - } - - public GlyfTable get_glyf_table () { - return glyf_table; - } - public long get_font_file_size () { long length = 0; @@ -52,8 +52,6 @@ class Path { public double g = 0; public double b = 0; public double a = 1;-- private string? name = null; bool selected = false; @@ -80,11 +78,6 @@ class Path { this.a = a; } - public double get_width () {- return_if_fail (xmax != double.MIN && xmin != double.MAX);- return (xmax - xmin);- }- public bool empty () { return points.length () == 0; }@@ -291,41 +284,6 @@ class Path { cr.restore (); } - public static void draw_edit_point_center_testing (EditPoint e, Context cr) {- Glyph g = MainWindow.get_current_glyph ();- - double ivz = 1 / g.view_zoom;-- double xc = g.allocation.width / 2.0;- double yc = g.allocation.height / 2.0;-- double x = xc + e.x;- double y = yc - e.y;-- double thickness = (e.active) ? 5 * ivz : 4 * ivz;-- if (e.active) - cr.set_source_rgba (1, 0, 0, 1);- else- cr.set_source_rgba (e.r, e.g, e.b, e.a);-- cr.set_line_width (thickness);-- cr.new_path ();- - cr.move_to (x - 0.7 * ivz, y - 0.7 * ivz);- cr.line_to (x + 0.7 * ivz, y + 0.7 * ivz);- - cr.move_to (x + 0.7 * ivz, y - 0.7 * ivz);- cr.line_to (x - 0.7 * ivz, y + 0.7 * ivz);- - cr.close_path ();-- cr.stroke ();-- cr.save (); - }- /** Returns true if there is an edit point at (p.x, p.y). */ private bool has_edit_point (EditPoint p) { foreach (var t in points) {@@ -335,60 +293,6 @@ class Path { } return false; }- - private bool force_union_directions (Path union) {- bool r;- - r = force_union_direction (union); // do force direction- r = force_union_direction (union); // check result, direction should not change- - if (unlikely (!r)) {- warning ("Path direction is still not correct.");- }- - return true;- }- - private bool force_union_direction (Path union) {- EditPoint? e;- unowned List<EditPoint>? ed;- EditPoint ep;- EditPoint next;- - create_list ();- union.create_list ();- - foreach (var p in points) {- e = union.get_edit_point_at (p.x, p.y);- - if (e != null) {- ep = (!) e;- ed = ep.get_next ();- - if (unlikely (ed != null)) {- warning ("next edit point is null");- return false;- }- - next = ((!)ed).data;- - if (is_over_coordinate (ep.x, ep.y)) {- union.reverse ();- return false;- }- }- }- - return true;- }- - private bool has_edit_point_at (double x, double y) {- foreach (var p in points) {- if (p.x == x && p.y == y) return true;- }- - return false;- } private EditPoint? get_edit_point_at (double x, double y) { foreach (var p in points) {@@ -1084,7 +988,6 @@ class Path { public Path get_quadratic_points () { EditPoint middle = new EditPoint (); unowned List<EditPoint> e;- int i = 0; EditPointHandle eh; quadratic_path = copy ();@@ -1125,7 +1028,7 @@ class Path { } void convert_to_quadratic (Path cubic_path, EditPoint middle) {- double curve_x, curve_y, distance; + double curve_x, curve_y; EditPointHandle eh; EditPoint start = middle.get_prev ().data;@@ -1664,11 +1567,8 @@ class Path { private static bool try_merge (Path p0, Path p1, out PathList path_list) { EditPoint e; IntersectionList il;- int i;- bool over; Path np;- Path np_counter; unowned List<Path> pi; @@ -1739,11 +1639,6 @@ class Path { for (i = 0; i < path_list.paths.length (); i++) { pi = path_list.paths.nth (i); - print (@"\n");- foreach (var p in path_list.paths) {- print (@"Paths: $(is_clasped (path_list, p)) Length: $(p.points.length ())\n");- }- if (pi.data.is_clockwise () && is_clasped (path_list, pi.data)) { path_list.paths.remove_link (pi); i--;@@ -1804,7 +1699,7 @@ class Path { return true; } }- + return false; } @@ -1828,7 +1723,6 @@ class Path { uint len_i; int i, j; uint len_j;- bool over; Path np = new Path (); Intersection s = new Intersection (0, 0, 1); @@ -1937,125 +1831,7 @@ class Path { return true; }- - private static bool create_merged_path (IntersectionList il, Path p0, Path p1, out Path new_path) {- EditPoint ex;- EditPoint ix;- uint offset_i = 0;- uint offset_j;- uint len_i;- int i, j;- uint len_j;- bool over;- Path np = new Path ();- Intersection s = new Intersection (0, 0, 1);- - ex = p0.points.last ().data;- ix = p0.points.last ().data;- len_i = p0.points.length ();- - for (i = 0; i < p0.points.length (); i++) {- ex = p0.points.nth ((i + offset_i) % len_i).data; - if (ex == p0.points.first ().data && i != 0) { - break;- }-- // add new point for path a- if (np.has_edit_point (ex)) {- // SPLIT- warning ("Merged path need split");- np.close ();- new_path = np;- return false;- } else {- np.add_point (ex);- ex.recalculate_linear_handles ();- }- - // swap paths- if (il.has_edit_point (ex)) {- s = (!) il.get_intersection (ex);- il.remove_point (ex);- - ex.type = PointType.CURVE;- ex.right_handle.type = PointType.CURVE;- ex.right_handle.angle = s.editpoint_b.right_handle.angle;- ex.right_handle.length = s.editpoint_b.right_handle.length;-- ex.left_handle.type = PointType.CURVE;-- // read until we find ex- for (j = 0; j < p1.points.length (); j++) {- ix = p1.points.nth (j).data;- - if (ix == s.editpoint_b) {- break;- }- }- - offset_j = j + 1;- len_j = p1.points.length ();- for (j = 0; j < p1.points.length (); j++) {- - ix = p1.points.nth ((j + offset_j) % len_j).data;- - // add- if (np.has_edit_point (ix)) {- // SPLIT- warning ("Merged path need split");- np.close ();- new_path = np;- return false;- } else {- np.add_point (ix);- ix.recalculate_linear_handles ();- }- - if (il.has_edit_point (ix)) {- s = (!) il.get_intersection (ix);- il.remove_point (ix);- break;- }- }-- ix.type = PointType.CURVE;- ix.right_handle.type = PointType.CURVE;- ix.right_handle.angle = s.editpoint_a.right_handle.angle;- ix.right_handle.length = s.editpoint_a.right_handle.length;- - ix.left_handle.type = PointType.CURVE;- - if (j == p0.points.length ()) {- np.close ();- new_path = np;- return true;- }-- // skip to next intersection- int k;- for (k = 0; k < p0.points.length (); k++) {- ix = p0.points.nth (k).data; -- if (ix == s.editpoint_a) {- break;- }- }- - if (k == p0.points.length ()) {- new_path = np;- return true;- }- - offset_i = 0;- i = k;- }- }- - new_path = np;- - return true;- } } class PathList : GLib.Object {@@ -285,7 +285,6 @@ class PenTool : Tool { Glyph g = MainWindow.get_current_glyph (); EditPoint e;- EditPoint ep = (!) g.new_point_on_path; double rax, ray; double pax, pay;@@ -388,11 +387,6 @@ class PenTool : Tool { } }- - public static bool is_move_point_selected () {- Tool t = MainWindow.get_toolbox ().get_tool ("move_point");- return t.is_selected ();- } public static bool insert_new_point_on_path_selected () { Tool t = MainWindow.get_toolbox ().get_tool ("insert_point_on_path");@@ -408,16 +402,6 @@ class PenTool : Tool { return t.is_selected (); } - public static bool is_new_point () {- Tool t = MainWindow.get_toolbox ().get_tool ("new_point");- return t.is_selected ();- }-- public static bool is_corner_selected () {- Tool t = MainWindow.get_toolbox ().get_tool ("corner");- return t.is_selected ();- }- public static bool is_erase_selected () { Tool t = MainWindow.get_toolbox ().get_tool ("erase_tool"); return t.is_selected ();@@ -32,8 +32,6 @@ class Preview : FontDisplay { return true; } - bool b = false;- public override void selected_canvas () { WebView w = MainWindow.get_webview (); string uri = get_uri ();@@ -50,8 +48,6 @@ class Preview : FontDisplay { if (Supplement.win32) { TimeoutSource t1 = new TimeoutSource (300); t1.set_callback (() => {- File layout_dir = FontDisplay.find_layout_dir ();- File layout_uri = layout_dir.get_child (get_html_file ()); w.load_html_string ("<html><body>Loading ...</body></html>", uri); return false; });@@ -92,10 +92,6 @@ class Scrollbar : DrawingArea { move = false; } - public double get_height () {- return alloc.height;- }- public void motion_notify (EventMotion e) { double d = 0; double dl = 0;@@ -24,8 +24,7 @@ class Svg { /** Export to svg glyph data. */ public static string to_svg_glyph (Glyph g, double scale = 1) { StringBuilder svg = new StringBuilder ();- Glyph gl;- + foreach (Path pl in g.path_list) { write_path_as_glyph (pl, svg, g, scale); }@@ -45,7 +45,6 @@ class TestCases { public static void test_over_path () { Glyph g; Path p = new Path ();- Path p2 = new Path (); Tool pen_tool; pen_tool = MainWindow.get_toolbox ().get_tool ("pen_tool");@@ -102,16 +102,6 @@ class Tool : GLib.Object { b = b_default; } - public void set_default_color (double r, double g, double b) {- r_default = r;- g_default = g;- b_default = b;- - this.r = r;- this.g = g;- this.b = b;- }- public void set_icon (string name) { StringBuilder n = new StringBuilder (); n.append ((!) name);