Clone in a terminal:
Commit 74ebd64
Johan Mattsson - 2012-09-21T22:06:12+00:00
74ebd64e02fbf224875986de948f0b43a6501996johan.mattsson.m@gmail.com

continue drawing path from the other end

Changed files (13)

Diff

diff --git a/icons/tab1_left.png b/icons/tab1_left.pngindex 5d0dc54..0b02dc7 100644Binary files a/icons/tab1_left.png and b/icons/tab1_left.png differdiff --git a/src/Birdfont.vala b/src/Birdfont.valaindex 6468dd9..e27e169 100644--- a/src/Birdfont.vala+++ b/src/Birdfont.vala@@ -237,8 +237,7 @@ public static string wine_to_unix_path (string exec_path) { 	bool drive_c, drive_z; 	int i; 	string p, q;-	File f;-	+ 	p = exec_path; 	p = p.replace ("\\", "/"); 	diff --git a/src/CutBackgroundTool.vala b/src/CutBackgroundTool.valaindex 98c63ea..4fd5076 100644--- a/src/CutBackgroundTool.vala+++ b/src/CutBackgroundTool.vala@@ -222,12 +222,17 @@ class CutBackgroundTool : Tool {  		img_file_next = img_dir.get_child (fn); 		-		if (img_file_next.query_exists ()) {-			img_file_next.delete ();-		}--		img_file.set_display_name (fn);+		try {+			if (img_file_next.query_exists ()) {+				img_file_next.delete ();+			} +			img_file.set_display_name (fn);+		} catch (GLib.Error e) {+			warning (e.message);+			return;+		}+		 		newbg = new GlyphBackgroundImage ((!) f.get_backgrounds_folder ().get_child ("parts").get_child (fn).get_path ()); 		 		// set position for the new backgrounddiff --git a/src/EditPoint.vala b/src/EditPoint.valaindex 031e5ac..faca272 100644--- a/src/EditPoint.vala+++ b/src/EditPoint.vala@@ -198,35 +198,6 @@ class EditPoint { 		eh.move_to_coordinate (right_handle.x (), right_handle.y ()); 	} -	public void set_point_type (PointType point_type) {-		type = point_type;-	}--	public double get_average_angle () {-		double a, b, c, length, angle;--		recalculate_linear_handles ();-		-		a = left_handle.x () - right_handle.x ();-		b = left_handle.y () - right_handle.y ();-		c = a * a + b * b;-		-		if (c == 0) {-			warning ("Can't calculate average length");-			return 0;-		}-		-		length = sqrt (fabs (c));-		-		if (right_handle.y () < left_handle.y ()) {-			angle = acos (a / length) + PI;		-		} else {-			angle = -acos (a / length) + PI;-		}	-		-		return angle;-	}- 	public EditPoint copy () { 		EditPoint new_point = new EditPoint (); 		diff --git a/src/ExportTool.vala b/src/ExportTool.valaindex 035f4ad..b936ffb 100644--- a/src/ExportTool.vala+++ b/src/ExportTool.vala@@ -178,14 +178,14 @@ class ExportTool : Tool { 		prefered_browser = "sensible-browser"; 		return (!) prefered_browser; 	}-	+ 	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));-+		DataOutputStream os; 		string name = font.get_name ();  		try {+			os = new DataOutputStream (file.create(FileCreateFlags.REPLACE_DESTINATION));  os.put_string ( """<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">@@ -404,9 +404,6 @@ os.put_string ( 	 	public static bool export_ttf_font_path (File folder, bool async = true) { 		Font current_font = Supplement.get_current_font ();-		string path;-		OpenFontFormatWriter fo;-		Font temp_font = new Font (); 		File ttf_file; 		File eot_file; 		string temp_file;diff --git a/src/FileSelection.vala b/src/FileSelection.valaindex 6ec68c1..eed79cf 100644--- a/src/FileSelection.vala+++ b/src/FileSelection.vala@@ -67,11 +67,6 @@ class FileSelection {     time.attach (null); 	} 	-	public void set_path (string fn) {-		path = new StringBuilder ();-		path.append (fn);-	}-	 	public void draw (Allocation allocation, Context cr) { 		FontExtents fe; 		diff --git a/src/Font.vala b/src/Font.valaindex 1861107..cb530fe 100644--- a/src/Font.vala+++ b/src/Font.vala@@ -105,10 +105,6 @@ class Font : GLib.Object { 		return f; 	} -	public uint get_length () {-		return glyph_names.length ();-	}- 	/** Retuns true if the current font has be modified */ 	public bool is_modified () { 		return modified;@@ -177,12 +173,6 @@ class Font : GLib.Object { 		return name; 	} -	public GlyphRange get_available_glyph_ranges () {-		GlyphRange gr = new GlyphRange ();-		gr.unassigned = glyph_names;-		return gr;-	}- 	public void print_all () { 		stdout.printf ("Assigned:\n");		 		glyph_cache.for_each((g) => {@@ -306,7 +296,6 @@ class Font : GLib.Object {  	public void add_glyph_collection (GlyphCollection glyph_collection) { 		GlyphCollection? gc = get_cached_glyph_collection (glyph_collection.get_name ());-		unowned List<string>? nl; 		 		if (glyph_collection.get_name () == "") { 			warning ("Refusing to insert glyph with name \"\", null character should be named null.");@@ -390,7 +379,6 @@ class Font : GLib.Object {  	public GlyphCollection? get_cached_glyph_collection (string glyph) { 		GlyphCollection? gc = null;-		Glyph? new_glyph; 		 		gc = glyph_cache.get (glyph); 		@@ -576,23 +564,27 @@ class Font : GLib.Object { 			}); 		 			glyph_cache.for_each ((gc) => {-				Glyph glyph = gc.get_current ();-				-				foreach (Kerning k in glyph.kerning) {-					string l, r;-					Glyph? gr = get_glyph (k.glyph_right);-					Glyph glyph_right;+				try {+					Glyph glyph = gc.get_current (); 					-					if (gr == null) {-						warning ("kerning glyph that does not exist.");+					foreach (Kerning k in glyph.kerning) {+						string l, r;+						Glyph? gr = get_glyph (k.glyph_right);+						Glyph glyph_right;+						+						if (gr == null) {+							warning ("kerning glyph that does not exist.");+						}+						+						glyph_right = (!) gr;+						+						l = Font.to_hex_code (glyph.unichar_code);+						r = Font.to_hex_code (glyph_right.unichar_code);+										+						os.put_string (@"<hkern left=\"U+$l\" right=\"U+$r\" kerning=\"$(k.val)\"/>\n"); 					}-					-					glyph_right = (!) gr;-					-					l = Font.to_hex_code (glyph.unichar_code);-					r = Font.to_hex_code (glyph_right.unichar_code);-									-					os.put_string (@"<hkern left=\"U+$l\" right=\"U+$r\" kerning=\"$(k.val)\"/>\n");+				} catch (GLib.Error e) {+					warning (e.message); 				} 			}); @@ -600,7 +592,6 @@ class Font : GLib.Object { 				GlyphBackgroundImage bg; 				 				try {-					bool selected; 					string data; 					 					foreach (Glyph g in gc.get_version_list ().glyphs) {@@ -1021,11 +1012,15 @@ class Font : GLib.Object { 			return; 		} 		-		file_stream = img_file.create (FileCreateFlags.REPLACE_DESTINATION);-		png_stream = new DataOutputStream (file_stream);+		try {+			file_stream = img_file.create (FileCreateFlags.REPLACE_DESTINATION);+			png_stream = new DataOutputStream (file_stream); -		png_stream.write (Base64.decode (data));-		png_stream.close ();+			png_stream.write (Base64.decode (data));+			png_stream.close ();	+		} catch (GLib.Error e) {+			warning (e.message);+		} 	} 	 	private void parse_background (Xml.Node* node) diff --git a/src/Glyph.vala b/src/Glyph.valaindex acd99ec..151815e 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -237,7 +237,6 @@ class Glyph : FontDisplay { 	}  	public void set_background_image (GlyphBackgroundImage? b) {-		double default_img_offset_x, default_img_offset_y; 		GlyphBackgroundImage bg; 		 		if (b == null) {@@ -742,11 +741,6 @@ class Glyph : FontDisplay { 		return (int) (-y); 	} -	public static void reverse (double x, double y, out int rx, out int ry) {-		rx = Glyph.reverse_path_coordinate_x (x);-		ry = Glyph.reverse_path_coordinate_y (y);		-	}	- 	public bool select_path (double x, double y) { 		Path? p = null; 		bool found = false;@@ -1670,9 +1664,6 @@ class Glyph : FontDisplay { 	 	/** Merge selected paths. */ 	public void merge_all () {-		bool merged = false;-		bool m = false;-		 		store_undo_state (); 		delete_invisible_paths (); 		@@ -1695,10 +1686,8 @@ class Glyph : FontDisplay { 	} 	 	public bool merge_path (Path p0) {-		Path? m; 		Path mp; 		PathList path_list;-		int i = 0; 		 		foreach (Path p1 in active_paths) { 			if (p0 == p1) {diff --git a/src/GlyphBackgroundImage.vala b/src/GlyphBackgroundImage.valaindex d52c171..cdc79ac 100644--- a/src/GlyphBackgroundImage.vala+++ b/src/GlyphBackgroundImage.vala@@ -44,7 +44,6 @@ class GlyphBackgroundImage { 	private bool desaturate = false; 	private double threshold = 1.0; 	-	private bool update_sheduled = false;	 	private bool background_image_is_processing = false;  	public signal void updated ();@@ -123,25 +122,31 @@ class GlyphBackgroundImage { 	}  	public bool is_valid () {+		FileInfo file_info; 		File file = File.new_for_path (path); 	 		if (!file.query_exists ()) { 			return false; 		} 		-		var file_info = file.query_info ("*", FileQueryInfoFlags.NONE);-		-		if (file_info.get_size () == 0) {+		try {+			file_info = file.query_info ("*", FileQueryInfoFlags.NONE);+			+			if (file_info.get_size () == 0) {+				return false;+			}+		} catch (GLib.Error e) {+			warning (e.message); 			return false; 		}-		+				 		return true; 	}  	public string get_png_base64 () { 		try { 			File file = File.new_for_path (path);-			var file_info = file.query_info ("*", FileQueryInfoFlags.NONE);+			FileInfo file_info = file.query_info ("*", FileQueryInfoFlags.NONE); 			uint8[] buffer = new uint8[file_info.get_size ()]; 			FileInputStream file_stream; 			DataInputStream png_stream;@@ -204,8 +209,6 @@ class GlyphBackgroundImage { 	} 	 	private void create_png () {-		ImageSurface img;-		Context ct; 		string fn = @"$path.png"; 		 		Font font = Supplement.get_current_font ();@@ -220,9 +223,13 @@ class GlyphBackgroundImage { 			return; 		} 		-		pixbuf = new Pixbuf.from_file (path);-		pixbuf.save ((!) png_image.get_path (), "png");-		path = (!) png_image.get_path ();+		try {+			pixbuf = new Pixbuf.from_file (path);+			pixbuf.save ((!) png_image.get_path (), "png");+			path = (!) png_image.get_path ();+		} catch (GLib.Error e) {+			warning (e.message);+		} 	} 	 	public double get_current_width () {@@ -413,7 +420,6 @@ class GlyphBackgroundImage { 	}  	void img_center (out double x, out double y) {-		double a, b; 		Glyph g = MainWindow.get_current_glyph (); 		 		x = img_offset_x - g.view_offset_x + (size_margin / 2) * img_scale_x;@@ -438,7 +444,7 @@ class GlyphBackgroundImage {  	bool is_over_resize (double nx, double ny) { 		Glyph g = MainWindow.get_current_glyph ();-		double x, y, cx, cy, size, w, h;+		double x, y, cx, cy, size; 		bool inx, iny;  		size = 12 * g.view_zoom;@@ -494,7 +500,7 @@ class GlyphBackgroundImage { 	} 		 	public void draw_rotate_handle (Context cr, Glyph g) {-		double x, y, hx, hy, x1, y1, x2, y2;+		double x, y, hx, hy, x2, y2; 		 		double ivz = 1.0 / (g.view_zoom); 		diff --git a/src/GlyphRange.vala b/src/GlyphRange.valaindex c9bc5d4..d12481d 100644--- a/src/GlyphRange.vala+++ b/src/GlyphRange.vala@@ -169,8 +169,6 @@ class GlyphRange { 	}  	public string get_char (uint32 index) {-		uint i = 0;-		uint next = 0; 		int64 ti; 		string chr; 		UniRange r;diff --git a/src/GlyphTable.vala b/src/GlyphTable.valaindex cf14426..91efb16 100644--- a/src/GlyphTable.vala+++ b/src/GlyphTable.vala@@ -179,10 +179,6 @@ class GlyphTable : GLib.Object { 			return (ac < bc) ? 1 : -1; 		} 		-		if (ac == bc) {-			return 0;-		}-		 		return (ac < bc) ? 1 : -1; 	} 	@@ -282,7 +278,6 @@ class GlyphTable : GLib.Object { 	unowned List<Item>? find_next_via_index (string n) { 		unowned List<Item> i = data.first (); 		unowned List<RowItem> r;-		unowned List<Item> start, stop; 		int cmp; 		 		if (data.length () == 0) {diff --git a/src/PenTool.vala b/src/PenTool.valaindex b15a285..275e42e 100644--- a/src/PenTool.vala+++ b/src/PenTool.vala@@ -282,7 +282,14 @@ class PenTool : Tool { 			if (active_edit_point != null) { 				selected_corner = (!) active_edit_point; 			}-		}		+		}+		+		// continue adding points from the selected one+		foreach (Path p in glyph.active_paths) {+			if (p.points.length () > 0 && active_edit_point == p.points.first ().data) {+				p.reverse ();+			}+		} 	} 	 	public void move_current_point_on_path (double x, double y) {@@ -376,7 +383,7 @@ class PenTool : Tool { 		y *= -1;  		set_active_edit_point (null);-+		 		foreach (Path current_path in g.path_list) { 			foreach (EditPoint e in current_path.points) { 				d = Math.sqrt (Math.fabs (Math.pow (e.x - x, 2) + Math.pow (e.y - y, 2)));diff --git a/src/TabBar.vala b/src/TabBar.valaindex e66e607..fb52aaa 100644--- a/src/TabBar.vala+++ b/src/TabBar.vala@@ -42,7 +42,9 @@ class TabBar : DrawingArea {  	ImageSurface? tab3_left = null; 	ImageSurface? tab3_right = null;-				+	+	ImageSurface? bar_background = null;+	 	public TabBar () { 		tab1_left = Icons.get_icon ("tab1_left.png"); 		tab1_right = Icons.get_icon ("tab1_right.png");@@ -52,7 +54,9 @@ class TabBar : DrawingArea {  		tab3_left = Icons.get_icon ("tab3_left.png"); 		tab3_right = Icons.get_icon ("tab3_right.png");-				+		+		bar_background = Icons.get_icon ("tabbar_background.png");+		 		set_extension_events (ExtensionMode.CURSOR | EventMask.POINTER_MOTION_MASK); 		add_events (EventMask.BUTTON_PRESS_MASK | EventMask.POINTER_MOTION_MASK | EventMask.LEAVE_NOTIFY_MASK); 	  @@ -353,6 +357,11 @@ class TabBar : DrawingArea { 		cr.stroke (); 		cr.restore (); +		for (int j = 0; j < alloc.width; j++) {+			cr.set_source_surface ((!) bar_background, j, 0);+			cr.paint ();+		}+ 		draw_tabs (cr); 	} 	

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112