Clone in a terminal:
Commit 7d4c736
Johan Mattsson - 2014-02-14T12:04:08+00:00
7d4c7368a1e5ea228dbf4f761d5f61a4f82262ccjohan.mattsson.m@gmail.com

Merge branch 'master' of gitorious.org:birdfont/birdfont

Changed files (12)

Diff

diff --git a/NEWS b/NEWSindex bd450d0..318dfe1 100644--- a/NEWS+++ b/NEWS@@ -1,3 +1,19 @@+birdfont (0.33) stable;++  * Background images on new versions of Mac OS X and other bug fixes.++ -- Johan Mattsson <johan.mattsson.m@gmail.com>  Wed Feb 12 21:22:18 CET 2014++birdfont (0.32) stable;++  * Touch screen friendly interface+  * New tools for adding and moving control points+  * Icons in 320 dpi+  * French translation+  * Bug fixes++ -- Johan Mattsson <johan.mattsson.m@gmail.com>  Tue Feb 11 08:53:15 CET 2014+ birdfont (0.31) stable;    * Bug fixes@@ -126,7 +142,7 @@ birdfont (0.15) stable;  birdfont (0.14) stable; -  * Bugfixes+  * Bug fixes   -- Johan Mattsson <johan.mattsson.m@gmail.com>  Sun Feb 24 17:43:00 CET 2013 @@ -146,19 +162,19 @@ birdfont (0.13) stable;  birdfont (0.12) stable; -  * Bugfixes and updated test suit+  * Bug fixes and updated test suit   -- Johan Mattsson <johan.mattsson.m@gmail.com>  Thu Jan 31 19:01:04 CET 2013  birdfont (0.11) stable; -  * Bugfixes+  * Bug fixes   -- Johan Mattsson <johan.mattsson.m@gmail.com>  Wed Jan 30 09:25:10 CET 2013  birdfont (0.10) stable; -  * Bugfixes+  * Bug fixes   * Move paths with keyboard   * Backup and crash recovery @@ -195,7 +211,7 @@ birdfont (0.8) stable; birdfont (0.7) stable;    * New icons-  * Bugfixes+  * Bug fixes   * Menu   * Internationalization @@ -205,7 +221,7 @@ birdfont (0.6) stable;    * Improved TrueType outlines   * Resize paths-  * Bugfixes+  * Bug fixes   -- Johan Mattsson <johan.mattsson.m@gmail.com>  Sun Oct 28 18:38:35 CET 2012 @@ -221,7 +237,7 @@ birdfont (0.5) stable; birdfont (0.4.1) stable;    * Edit filled paths-  * Bugfixes+  * Bug fixes   -- Johan Mattsson <johan.mattsson.m@gmail.com>  Wed Sep 19 15:37:40 CEST 2012 diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex 66901e9..c9107c0 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012, 2013 Johan Mattsson+    Copyright (C) 2012, 2013, 2014 Johan Mattsson      This program is free software: you can redistribute it and/or modify     it under the terms of the GNU General Public License as published by@@ -20,6 +20,7 @@ using Gtk; using Gdk; using BirdFont; using WebKit;+using Gdk;  namespace BirdFont { @@ -835,6 +836,20 @@ public class GtkWindow : Gtk.Window, NativeWindow { 		text_entry.grab_focus (); 		text_input_is_active = true; 	}+	+	public bool convert_to_png (string from, string to) {+		Pixbuf pixbuf;+		+		try {+			pixbuf = new Pixbuf.from_file (from);+			pixbuf.save (to, "png");+		} catch (GLib.Error e) {+			warning (e.message);+			return false;+		}+		+		return true;+	} }  class TabbarCanvas : DrawingArea {diff --git a/graphics/tools_and_buttons.svg b/graphics/tools_and_buttons.svgindex 69b3b70..b0d2031 100644--- a/graphics/tools_and_buttons.svg+++ b/graphics/tools_and_buttons.svg@@ -23,6 +23,18 @@      id="defs3788">     <linearGradient        inkscape:collect="always"+       id="linearGradient3575">+      <stop+         style="stop-color:#d5e5ff;stop-opacity:1;"+         offset="0"+         id="stop3577" />+      <stop+         style="stop-color:#d5e5ff;stop-opacity:0;"+         offset="1"+         id="stop3579" />+    </linearGradient>+    <linearGradient+       inkscape:collect="always"        id="linearGradient4635">       <stop          style="stop-color:#e7e6e6;stop-opacity:1;"@@ -382,6 +394,17 @@        y2="743"        gradientUnits="userSpaceOnUse"        gradientTransform="matrix(1.2890276,0,0,1,-73.718994,-5)" />+    <radialGradient+       inkscape:collect="always"+       xlink:href="#linearGradient3575"+       id="radialGradient3581"+       cx="199.80905"+       cy="24.502512"+       fx="199.80905"+       fy="24.502512"+       r="30.703518"+       gradientUnits="userSpaceOnUse"+       gradientTransform="matrix(1.696811,-0.06964229,0.06038833,1.4713414,-140.70881,2.3661124)" />   </defs>   <sodipodi:namedview      id="base"@@ -391,8 +414,8 @@      inkscape:pageopacity="0.0"      inkscape:pageshadow="2"      inkscape:zoom="1"-     inkscape:cx="204.06067"-     inkscape:cy="568.36736"+     inkscape:cx="-152"+     inkscape:cy="796.5"      inkscape:current-layer="layer1"      inkscape:document-units="px"      showgrid="false"@@ -1811,5 +1834,18 @@          id="tspan4601"          x="11.868663"          y="389.10025">AV</tspan></text>+    <path+       sodipodi:type="arc"+       style="opacity:0.72016458000000005;fill:url(#radialGradient3581);fill-opacity:1"+       id="path3573"+       sodipodi:cx="200.75377"+       sodipodi:cy="25.919598"+       sodipodi:rx="30.703518"+       sodipodi:ry="30.703518"+       d="m 231.45729,25.919598 a 30.703518,30.703518 0 1 1 -61.40704,0 30.703518,30.703518 0 1 1 61.40704,0 z"+       transform="translate(13.934673,8.0301508)"+       inkscape:export-filename="/home/johan/birdfont/icons/delay_circle.png"+       inkscape:export-xdpi="319.88824"+       inkscape:export-ydpi="319.88824" />   </g> </svg>diff --git a/icons/delay_circle.png b/icons/delay_circle.pngnew file mode 100644index 0000000..6103d43Binary files /dev/null and b/icons/delay_circle.png differdiff --git a/install.py b/install.pyindex 1bc68d1..bfd328d 100755--- a/install.py+++ b/install.py@@ -98,6 +98,7 @@ elif os.path.isfile ('build/libbirdfont.so.' + version.SO_VERSION): elif os.path.isfile ('build/bin/libbirdfont.' + version.SO_VERSION + '.dylib'): 	install ('build/bin/libbirdfont.' + version.SO_VERSION + '.dylib', libdir, 644) 	link (libdir, 'libbirdfont.' + version.SO_VERSION + '.dylib', ' libbirdfont.dylib.' + version.SO_VERSION_MAJOR)+	link (libdir, 'libbirdfont.' + version.SO_VERSION + '.dylib', ' libbirdfont.dylib') else: 	print ("Can not find libbirdfont.") 	exit (1)diff --git a/libbirdfont/BackgroundSelection.vala b/libbirdfont/BackgroundSelection.valaindex 678b1f1..3776692 100644--- a/libbirdfont/BackgroundSelection.vala+++ b/libbirdfont/BackgroundSelection.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012 Johan Mattsson+    Copyright (C) 2012, 2013, 2014 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 @@ -87,31 +87,43 @@ class BackgroundSelection : FontDisplay { 	} 	 	private ImageSurface create_thumbnail (string file) throws GLib.Error {-#if !ANDROID-		Pixbuf pixbuf;-		+		ImageSurface img_surface;+		ImageSurface thumbnail_surface;+		Cairo.Status status;+		GlyphBackgroundImage background_image;+		Context cr;+		double ratio; 		Font font = BirdFont.get_current_font (); 		File folder = font.get_backgrounds_folder (); 		string fn = Checksum.compute_for_string (ChecksumType.SHA1, file); 		File original = File.new_for_path (file);-		File thumbnail_path = folder.get_child (@"thumbnail");-		File png_image = thumbnail_path.get_child (@"$(fn).png");-		-		if (!thumbnail_path.query_exists ()) {-			DirUtils.create ((!) thumbnail_path.get_path (), 0xFFFFFF);+		File thumbnail_folder = folder.get_child (@"thumbnail");+		File thumbnail_image = thumbnail_folder.get_child (@"$(fn).png");+				+		if (!thumbnail_folder.query_exists ()) {+			DirUtils.create ((!) thumbnail_folder.get_path (), 0xFFFFFF); 		} 		-		if (!png_image.query_exists ()) {-			pixbuf = new Pixbuf.from_file_at_scale ((!) original.get_path (), 100, 100, true);-			if (!pixbuf.save ((!) png_image.get_path (), "png")) {-				warning (@"can't save $((!) png_image.get_path ())");+		if (!thumbnail_image.query_exists ()) {+			background_image = new GlyphBackgroundImage ((!) original.get_path ());+			img_surface = background_image.get_img ();+			thumbnail_surface = new ImageSurface (Format.ARGB32, 100, 100);+			ratio = Math.fmin (100.0 / img_surface.get_width (), 100.0 / img_surface.get_height ());+			cr = new Context (thumbnail_surface);+			+			cr.save ();+			cr.scale (ratio, ratio);+			cr.set_source_surface (img_surface, 0, 0);+			cr.paint ();+			cr.restore ();+			+			status = thumbnail_surface.write_to_png ((!) thumbnail_image.get_path ());+			if (status != Cairo.Status.SUCCESS) {+				warning (@"Can't save $((!) thumbnail_image.get_path ())"); 			} 		} 		-		return new ImageSurface.from_png ((!) png_image.get_path ());-#else-		return new ImageSurface (Format.ARGB32, 10, 10); // FIXME: android-#endif+		return new ImageSurface.from_png ((!) thumbnail_image.get_path ()); 	} 	 	private bool draw_thumbnail (string file, double x, double y, Context cr, int box_index) {@@ -187,7 +199,7 @@ class BackgroundSelection : FontDisplay { 			return; 		} 		-		file = background_images.nth (active_box - 1).data; // Fixa: check bounds+		file = background_images.nth (active_box - 1).data; 		bg = new GlyphBackgroundImage (file); 		tb = MainWindow.get_tab_bar (); 		diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 52d8451..8852039 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012, 2013 Johan Mattsson+    Copyright (C) 2012, 2013, 2014 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 @@ -641,7 +641,37 @@ public class DrawingTools : ToolCollection  { 			Preferences.set ("ttf_units", @"$(GridTool.ttf_units)"); 		}); 		style_tools.add_tool (ttf_units);++		// drawing tool delayed response in order to avoid having the +		// moving point untder the finger+#if ANDROID+		string delayed_response_value = Preferences.get ("response_delay");+		SpinButton delayed_response = new SpinButton ("response_delay", t_("Delay response for editing tools"));++		delayed_response.set_min (0);+		delayed_response.set_max (9);+				+		if (delayed_response_value != "") {+			delayed_response.set_value (delayed_response_value);+		} else {+			delayed_response.set_value_round (4);+		} 		+		delayed_response.new_value_action.connect ((self) => {+			MainWindow.get_toolbox ().select_tool (delayed_response);+			Preferences.set ("response_delay", self.get_display_value ());+			MainWindow.get_toolbox ().redraw ((int) delayed_response.x, (int) delayed_response.y, 70, 70);+		});++		delayed_response.select_action.connect((self) => {+			pen_tool.set_response_delay (((SpinButton)self).get_value ());+		});+		+		pen_tool.set_response_delay (delayed_response.get_value ());+		style_tools.add_tool (delayed_response);+#endif++		// selection policy 		draw_tools.set_open (true); 		draw_tool_modifiers.set_open (true); 		edit_point_modifiers.set_open (true);diff --git a/libbirdfont/GlyphBackgroundImage.vala b/libbirdfont/GlyphBackgroundImage.valaindex 5444349..5614b62 100644--- a/libbirdfont/GlyphBackgroundImage.vala+++ b/libbirdfont/GlyphBackgroundImage.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012 Johan Mattsson+    Copyright (C) 2012, 2013, 2014 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 @@ -14,7 +14,6 @@  using Cairo; using Math;-using Gdk;  namespace BirdFont { 	@@ -57,7 +56,8 @@ public class GlyphBackgroundImage { 	public int size_margin { 		get { 			if (unlikely (size == -1)) {-				size = (int) (Math.sqrt (Math.pow (get_img ().get_height (), 2) + Math.pow (get_img ().get_width (), 2)) + 0.5);+				size = (int) (Math.sqrt (Math.pow (get_img ().get_height (), 2) +					+ Math.pow (get_img ().get_width (), 2)) + 0.5); 			} 			 			return size;@@ -205,31 +205,30 @@ public class GlyphBackgroundImage { 	} 	 	private void create_png () {-#if !ANDROID-		string fn = @"$path.png";-		+		string file_name = @"$path.png"; 		Font font = BirdFont.get_current_font (); 		File folder = font.get_backgrounds_folder ();-		File original = File.new_for_path (fn);+		File original = File.new_for_path (file_name); 		File png_image = folder.get_child (@"full_$((!)original.get_basename ())");--		Pixbuf pixbuf;+		bool converted; 		 		if (png_image.query_exists ()) { 			path = (!) png_image.get_path (); 			return; 		} 		-		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);+		if (is_null (path)) {+			warning ("Background image path is null.");+			return; 		}-#endif--		// FIXME: android+		+		converted = MainWindow.native_window.convert_to_png (path, (!) png_image.get_path ());+		+		if (!converted) {+			warning ("Failed to convert image: $(path)");+		}+		+		path = (!) png_image.get_path (); 	} 	 	public void set_img_rotation_from_coordinate (double x, double y) {diff --git a/libbirdfont/KerningDisplay.vala b/libbirdfont/KerningDisplay.valaindex a60635d..454b704 100644--- a/libbirdfont/KerningDisplay.vala+++ b/libbirdfont/KerningDisplay.vala@@ -108,6 +108,7 @@ public class KerningDisplay : FontDisplay { 		x = 20; 		w = 0; 		prev = null;+		kern = 0; 		 		foreach (GlyphSequence word in row) { 			wi = 0;@@ -180,7 +181,7 @@ public class KerningDisplay : FontDisplay { 					cr.set_source_rgba (153/255.0, 153/255.0, 153/255.0, alpha); 					cr.move_to (x - w / 2.0 - 5, y + 20); 					cr.set_font_size (10);-					cr.show_text ("?"); // ?+					cr.show_text ("?"); 					cr.restore (); 				} 							@@ -190,6 +191,17 @@ public class KerningDisplay : FontDisplay { 				i++; 			} 			+			// draw caret+			if (first_row) {+				x2 = x + kern / 2.0;+				cr.save ();+				cr.set_source_rgba (0, 0, 0, 0.5);+				cr.move_to (x2, 20);+				cr.line_to (x2, 120);+				cr.stroke ();+				cr.restore ();+			}+			 			if (y > allocation.height && i > 10) { 				row.remove (word); 			}diff --git a/libbirdfont/NativeWindow.vala b/libbirdfont/NativeWindow.valaindex 566fce9..f835037 100644--- a/libbirdfont/NativeWindow.vala+++ b/libbirdfont/NativeWindow.vala@@ -48,6 +48,9 @@ public interface NativeWindow : GLib.Object {  	/** Exit the application. */ 	public abstract void quit ();++	/** Convert an image to PNG format. */+	public abstract bool convert_to_png (string from, string to); }  }diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex 2bd3cca..583b46e 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -1,5 +1,5 @@ /*-    Copyright (C) 2012, 2013 Johan Mattsson+    Copyright (C) 2012, 2013, 2014 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 @@ -23,6 +23,8 @@ public class PenTool : Tool { 	private static const double CONTACT_SURFACE = 20;  	public static bool move_selected = false;+	public static bool move_selected_handle = false;+ 	public static bool move_point_on_path = false;  	public static bool edit_active_corner = false;@@ -38,8 +40,6 @@ public class PenTool : Tool { 	 	public static EditPoint selected_point; -	public static bool move_selected_handle = false;- 	private static double last_point_x = 0; 	private static double last_point_y = 0; @@ -50,7 +50,17 @@ public class PenTool : Tool { 	private static double selection_box_last_y = 0;  	public static double precision = 1;+	+	public static double response_delay = 0;+	public static bool do_respond = false;+	private static const double RESPONSE_PIXELS = 20;+	+	// The pixel where the user pressed the mouse button+	public static int begin_action_x = 0; +	public static int begin_action_y = 0;+	 	private static ImageSurface? tie_icon = null;+	private static ImageSurface? delay_circle = null; 	 	/** First move action must move the current point in to the grid. */ 	bool first_move_action = false;@@ -86,6 +96,7 @@ public class PenTool : Tool { 		base (name, click_to_add_points + " " + t_("and double click to add new point on path."), ',', CTRL); 		 		tie_icon = Icons.get_icon ("tie_is_active.png");+		delay_circle = Icons.get_icon ("delay_circle.png"); 		 		select_action.connect ((self) => { 		});@@ -105,6 +116,11 @@ public class PenTool : Tool { 			clockwise = new List<Path> (); 			counter_clockwise = new List<Path> (); +			begin_action_x = x;+			begin_action_y = y;++			do_respond = false; // if the response is delayed+ 			foreach (Path p in glyph.path_list) { 				if (p.is_clockwise ()) { 					clockwise.append (p);@@ -143,6 +159,8 @@ public class PenTool : Tool { 			x = ix; 			y = iy; 			+			do_respond = true;+			 			join_paths (x, y);  			active_handle = new EditPointHandle.empty ();@@ -176,7 +194,12 @@ public class PenTool : Tool { 			selection_box_last_x = x; 			selection_box_last_y = y; 			-			move (x, y);+			if (isResponding (x, y)) {+				move (x, y);+			} else {+				last_point_x = x;+				last_point_y = y;+			} 		}); 		 		key_press_action.connect ((self, keyval) => {@@ -210,6 +233,22 @@ public class PenTool : Tool { 		}); 	} +	/** @return true after the initial delay.*/+	public static bool isResponding (int px, int py) {+		double d;+		+		if (!move_selected && !move_selected_handle) {+			do_respond = true;+		}+		+		if (!do_respond) {+			d = Math.sqrt (Math.pow (px - begin_action_x, 2) + Math.pow (py - begin_action_y, 2));+			do_respond = d > RESPONSE_PIXELS * response_delay;+		}+		+		return do_respond;+	}+ 	public static void select_points_in_box () { 		double x1, y1, x2, y2; 		Glyph g;@@ -295,6 +334,10 @@ public class PenTool : Tool { 		g.redraw_area (0, 0, g.allocation.width, g.allocation.height); 	} 	+	public void set_response_delay (double d) {+		response_delay = d;+	}+	 	public void set_precision (double p) { 		precision = p; 		DrawingTools.precision.set_value_round (p, false, false);@@ -382,7 +425,7 @@ public class PenTool : Tool { 			last_point_y = Glyph.precise_reverse_path_coordinate_y (selected_point.y); 		} else { 			last_point_x = x;-			last_point_y = y;			+			last_point_y = y; 		} 	} 	@@ -779,9 +822,34 @@ public class PenTool : Tool { 			draw_selection_box (cr); 		} 		+		if (!do_respond) {+			draw_delay_circle (cr);+		}+		 		draw_merge_icon (cr); 	} 	+	void draw_delay_circle (Context cr) {+		ImageSurface img;+		double x, y;+		double ratio;+		+		return_if_fail (delay_circle != null);+		+		img = (!) delay_circle;	+			+		cr.save ();+		ratio = 2 * RESPONSE_PIXELS * response_delay / img.get_width ();+		cr.scale (ratio, ratio);+		x = begin_action_x - ratio * img.get_width () / 2;+		x /= ratio;+		y = begin_action_y - ratio * img.get_height () / 2;+		y /= ratio;+		cr.set_source_surface (img, x, y);+		cr.paint ();+		cr.restore ();+	}+	 	void draw_selection_box (Context cr) { 		double x, y, w, h; diff --git a/scripts/version.py b/scripts/version.pyindex a240d37..83e761e 100644--- a/scripts/version.py+++ b/scripts/version.py@@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ -VERSION = '0.32'-SO_VERSION_MAJOR = '7'+VERSION = '0.33'+SO_VERSION_MAJOR = '8' SO_VERSION_MINOR = '0' SO_VERSION = SO_VERSION_MAJOR + '.' + SO_VERSION_MINOR

Contact

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