Clone in a terminal:
Commit 872a7ac
Johan Mattsson - 2016-06-13T11:03:23+00:00
872a7ac172cd55efbaae7f1a479305c38753814ajohan.mattsson.m@gmail.com

Merge ../birdfont-2.x

Changed files (12)

Diff

diff --git a/libbirdfont/AbstractMenu.vala b/libbirdfont/AbstractMenu.valaindex 39ee6ee..ca31619 100644--- a/libbirdfont/AbstractMenu.vala+++ b/libbirdfont/AbstractMenu.vala@@ -231,6 +231,7 @@ public class AbstractMenu : GLib.Object {  	public void add_tool_key_bindings () { 		ToolItem tool_item;+ 		foreach (ToolCollection tool_set in MainWindow.get_toolbox ().tool_sets) { 			foreach (Expander e in tool_set.get_expanders ()) { 				foreach (Tool t in e.tool) {diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex c623788..11d06dd 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -26,7 +26,7 @@ class BirdFontFile : GLib.Object { 	Font font; 	 	public static const int FORMAT_MAJOR = 2;-	public static const int FORMAT_MINOR = 1;+	public static const int FORMAT_MINOR = 2; 	 	public static const int MIN_FORMAT_MAJOR = 0; 	public static const int MIN_FORMAT_MINOR = 0;@@ -277,11 +277,25 @@ class BirdFontFile : GLib.Object { 		foreach (SpacingClass sc in s.classes) { 				os.put_string ("<spacing "); 				os.put_string ("first=\"");-				os.put_string (Font.to_hex (sc.first.get_char ()));+				+				if (sc.first.char_count () == 1) {+					os.put_string (Font.to_hex (sc.first.get_char ()));+				} else {+					os.put_string ("name:");+					os.put_string (XmlParser.encode (sc.first));+				}+				 				os.put_string ("\" "); 				 				os.put_string ("next=\"");-				os.put_string (Font.to_hex (sc.next.get_char ()));+				+				if (sc.next.char_count () == 1) {+					os.put_string (Font.to_hex (sc.next.get_char ()));+				} else {+					os.put_string ("name:");+					os.put_string (XmlParser.encode (sc.next));+				}+				 				os.put_string ("\" "); 				 				os.put_string ("/>\n");@@ -1128,6 +1142,7 @@ class BirdFontFile : GLib.Object { 	 	private void parse_spacing_class (Tag tag) { 		string first, next;+		string name; 		SpacingData spacing = font.get_spacing (); 		 		first = "";@@ -1135,11 +1150,21 @@ class BirdFontFile : GLib.Object { 		 		foreach (Attribute attr in tag.get_attributes ()) { 			if (attr.get_name () == "first") {-				first = (!) Font.to_unichar (attr.get_content ()).to_string ();+				if (attr.get_content ().has_prefix ("U+")) {+					first = (!) Font.to_unichar (attr.get_content ()).to_string ();+				} else if (attr.get_content ().has_prefix ("name:")) {+					name = attr.get_content ().substring ("name:".length);+					first = XmlParser.decode (name);+				} 			}  			if (attr.get_name () == "next") {-				next = (!) Font.to_unichar (attr.get_content ()).to_string ();+				if (attr.get_content ().has_prefix ("U+")) {+					next = (!) Font.to_unichar (attr.get_content ()).to_string ();+				} else if (attr.get_content ().has_prefix ("name:")) {+					name = attr.get_content ().substring ("name:".length);+					next = XmlParser.decode (name);+				} 			}		 		} 		@@ -1157,6 +1182,7 @@ class BirdFontFile : GLib.Object { 			 			foreach (Attribute attr in tag.get_attributes ()) { 				if (attr.get_name () == "left") {+ 					range_left.parse_ranges (unserialize (attr.get_content ())); 				} diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 2015ffe..7c7c717 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -192,9 +192,10 @@ public class DrawingTools : ToolCollection  { 		});	 		draw_tools.add_tool (move_background); -		move_canvas = new Tool ("move_canvas",-			t_("Move canvas"),-			t_("Press space and click to move the canvas."));+		move_canvas = new Tool ("move_canvas", t_("Move canvas") +			+ "\n" + t_("Ctrl + Shift + Click")+			+ "\n" + t_("Space + Click") + "\n");+ 		move_canvas.select_action.connect ((self) => { 			update_drawing_and_background_tools (self); 		});	diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 82799ea..b6d3912 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -1056,7 +1056,9 @@ public class Glyph : FontDisplay { 			return; 		} -		if (move_canvas || DrawingTools.move_canvas.is_selected ()) {+		if (move_canvas +			|| DrawingTools.move_canvas.is_selected ()+			|| (KeyBindings.has_ctrl () && KeyBindings.has_shift ())) { 			view_is_moving = true; 			move_offset_x = view_offset_x; 			move_offset_y = view_offset_y;@@ -1813,7 +1815,7 @@ public class Glyph : FontDisplay { 	private void move_view_offset (double x, double y) { 		view_offset_x = move_offset_x + (pointer_begin_x - x) * (1/view_zoom); 		view_offset_y = move_offset_y + (pointer_begin_y - y) * (1/view_zoom);-		redraw_area (0, 0, allocation.width, allocation.height);+		GlyphCanvas.redraw (); 	}  	public void store_undo_state (bool clear_redo = false) {@@ -2306,7 +2308,7 @@ public class Glyph : FontDisplay { 		SpacingData sd;  		sd = font.get_spacing ();-		s = sd.get_all_connections ((!) unichar_code.to_string ());+		s = sd.get_all_connections (get_name ());  		foreach (string l in s) { 			if (l != (!) unichar_code.to_string ()) {diff --git a/libbirdfont/GlyphSelection.vala b/libbirdfont/GlyphSelection.valaindex 4f1e97f..a0f584d 100644--- a/libbirdfont/GlyphSelection.vala+++ b/libbirdfont/GlyphSelection.vala@@ -27,7 +27,7 @@ public class GlyphSelection : OverView { 		FontDisplay.dirty_scrollbar = true;	 		 		open_glyph_signal.connect ((gc) => {-			selected_glyph (gc);+			selected_glyph (gc);			 			Toolbox.redraw_tool_box (); 		}); 		diff --git a/libbirdfont/OtfFeatureTable.vala b/libbirdfont/OtfFeatureTable.valaindex d12494a..c8873e7 100644--- a/libbirdfont/OtfFeatureTable.vala+++ b/libbirdfont/OtfFeatureTable.vala@@ -26,7 +26,7 @@ public class OtfFeatureTable : Table { 	static const int REPLACEMENT_GLYPH = 3; 	static const int ALTERNATE_ENTRY = 4; 	-	GlyphCollection glyph_collection;+	GlyphCollection? glyph_collection = null; 	GlyphCollection? replacement_glyph = null; 	string alternate_name = ""; 	TextListener listener;@@ -34,7 +34,7 @@ public class OtfFeatureTable : Table { 	Gee.ArrayList<AlternateItem> undo_items; 	// FIXME: implement redo 	-	public OtfFeatureTable (GlyphCollection gc) {+	public OtfFeatureTable (GlyphCollection? gc) { 		glyph_collection = gc; 		undo_items = new Gee.ArrayList<AlternateItem> (); 	}@@ -102,7 +102,15 @@ public class OtfFeatureTable : Table { 		row = new Row.headline (t_("Glyph Substitutions")); 		rows.add (row); 		-		row = new Row.columns_1 (t_("Glyph") + ": " + glyph_collection.get_name (), SOURCE_GLYPH, false);+		string glyph = "";+		+		if (glyph_collection == null) {+			glyph = t_("New glyph");+		} else {+			glyph = ((!) glyph_collection).get_name ();+		}+		+		row = new Row.columns_1 (t_("Glyph") + ": " + glyph, SOURCE_GLYPH, false); 		rows.add (row); 		 		string replacement = t_("New glyph");@@ -176,7 +184,14 @@ public class OtfFeatureTable : Table { 	}	  	public void add_new_alternate (string tag) {-		GlyphCollection gc = glyph_collection;+		GlyphCollection gc;+		+		if (glyph_collection == null) {+			MainWindow.show_message (t_("Select a glyph to create an alternate for."));+			return;+		}+		+		gc = (!) glyph_collection; 		 		listener = new TextListener (t_("Glyph name"), "", t_("Add")); 		@@ -190,19 +205,15 @@ public class OtfFeatureTable : Table { 			OverView overview = MainWindow.get_overview (); 			 			font = BirdFont.get_current_font ();-			-			if (alternate_name == "" || gc.is_unassigned ()) {-				MainWindow.tabs.close_display (this);-				return;-			}-			+ 			if (font.glyph_name.has_key (alternate_name)) { 				MainWindow.show_message (t_("All glyphs must have unique names.")); 			} else { 				alt = new GlyphCollection.with_glyph ('\0', alternate_name); 				alt.set_unassigned (true); 				font.add_new_alternate (gc, alt, tag);-				MainWindow.tabs.close_display (this);+				update_rows ();+				GlyphCanvas.redraw (); 				MainWindow.get_overview ().update_item_list (); 				overview.open_glyph_signal (alt); 			}@@ -212,7 +223,8 @@ public class OtfFeatureTable : Table { 			GlyphCollection replacement = (!) replacement_glyph; 			Font f = BirdFont.get_current_font (); 			f.add_alternate (gc.get_name (), replacement.get_name (), tag);-			MainWindow.tabs.close_display (this);+			update_rows ();+			GlyphCanvas.redraw (); 		} else { 			TabContent.show_text_input (listener); 		}		diff --git a/libbirdfont/OverviewTools.vala b/libbirdfont/OverviewTools.valaindex c4b1c7f..013ff55 100644--- a/libbirdfont/OverviewTools.vala+++ b/libbirdfont/OverviewTools.vala@@ -279,15 +279,16 @@ public class OverviewTools : ToolCollection  { 	public void add_new_alternate (Tool tool) { 		OverView o = MainWindow.get_overview (); 		OverViewItem oi = o.selected_item;-		GlyphCollection gc;+		GlyphCollection? gc; 		 		tool.set_selected (false); 		-		if (oi.glyphs == null || ((!) oi.glyphs).is_unassigned ()) {-			return;+		gc = (!) oi.glyphs;		+		+		if (oi.glyphs != null && ((!) oi.glyphs).is_unassigned ()) {+			gc = null; 		} 		-		gc = (!) oi.glyphs;		 		MainWindow.tabs.add_tab (new OtfFeatureTable (gc)); 	} 	diff --git a/libbirdfont/SpacingClass.vala b/libbirdfont/SpacingClass.valaindex 83c197d..a805d1d 100644--- a/libbirdfont/SpacingClass.vala+++ b/libbirdfont/SpacingClass.vala@@ -41,6 +41,11 @@ public class SpacingClass : GLib.Object  { 		update (next); 	} 	+	public void update_class (string value, bool first) {+		update_first = first;+		update (value);+	}+	 	void update (string val) { 		listener = new TextListener (t_("Character"), val, t_("Set")); 		@@ -48,7 +53,7 @@ public class SpacingClass : GLib.Object  { 			string v = text; 			 			if (v.has_prefix ("U+") || v.has_prefix ("u+")) {-				v = (!) Font.to_unichar (val).to_string ();+				v = ((!) Font.to_unichar (val).to_string ()).dup (); 			} 			 			if (update_first) {diff --git a/libbirdfont/SpacingClassTab.vala b/libbirdfont/SpacingClassTab.valaindex 910b969..44085e6 100644--- a/libbirdfont/SpacingClassTab.vala+++ b/libbirdfont/SpacingClassTab.vala@@ -20,13 +20,27 @@ public class SpacingClassTab : Table { 	 	public static int NEW_CLASS = -1; 	Gee.ArrayList<Row> rows = new Gee.ArrayList<Row> ();+	public static SpacingClass current_class;+	public static bool current_class_first_element; 	 	public SpacingClassTab () {+		current_class = new SpacingClass ("", ""); 	}  	public override Gee.ArrayList<Row> get_rows () { 		return rows; 	}+	+	public static void set_class (string glyph) {+		print(@"G: $(glyph)\n");+		if (current_class_first_element) {+			current_class.first = glyph;+		} else {+			current_class.next = glyph;+		}+		+		MainWindow.get_spacing_class_tab ().update_rows ();+	}  	public override void selected_row (Row row, int column, bool delete_button) { 		Font font = BirdFont.get_current_font ();@@ -51,11 +65,15 @@ public class SpacingClassTab : Table { 					warning (@"Index: $(row.get_index ()) classes.size: $(spacing.classes.size)"); 					return; 				}-				spacing.classes.get (row.get_index ()).set_first ();+				current_class = spacing.classes.get (row.get_index ());+				current_class.set_first ();+				current_class_first_element = true; 				font.touch (); 			} else if (column == 2) { 				return_if_fail (0 <= row.get_index () < spacing.classes.size);-				spacing.classes.get (row.get_index ()).set_next ();+				current_class = spacing.classes.get (row.get_index ());+				current_class.set_next ();+				current_class_first_element = false; 				font.touch (); 			} 		}diff --git a/libbirdfont/SpacingClassTools.vala b/libbirdfont/SpacingClassTools.valanew file mode 100644index 0000000..fc41fda--- /dev/null+++ b/libbirdfont/SpacingClassTools.vala@@ -0,0 +1,66 @@+/*+	Copyright (C) 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 +	published by the Free Software Foundation; either version 3 of the +	License, or (at your option) any later version.++	This library is distributed in the hope that it will be useful, but +	WITHOUT ANY WARRANTY; without even the implied warranty of +	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +	Lesser General Public License for more details.+*/++using Cairo;+using Math;++namespace BirdFont {++public class SpacingClassTools : ToolCollection  {+	public static Gee.ArrayList<Expander> expanders;++	public SpacingClassTools () {+		expanders = new Gee.ArrayList<Expander> ();++		Expander font_name = new Expander ();+		font_name.add_tool (new FontName ());+		+		Expander spacing_class_tools = new Expander ();+		Tool insert = new Tool ("insert_glyph_from_overview_in_spacing_class", t_("Insert glyph from overview"));+		+		insert.set_icon ("insert_glyph_from_overview");+		+		insert.select_action.connect ((self) => {+			GlyphSelection glyph_selection = new GlyphSelection ();+			+			glyph_selection.selected_glyph.connect ((glyph_collection) => {+				SpacingClassTab.set_class (glyph_collection.get_name ());+				MainWindow.get_tab_bar ().select_tab_name ("SpacingClasses");+			});+			+			GlyphCanvas.set_display (glyph_selection);+			self.set_selected (false);+			+			TabContent.hide_text_input ();+		});+		spacing_class_tools.add_tool (insert);+		+		expanders.add (font_name);+		+		expanders.add (spacing_class_tools);+	}+	+	public override Gee.ArrayList<Expander> get_expanders () {+		return expanders;+	}+	+	public override Gee.ArrayList<string> get_displays () {+		Gee.ArrayList<string> d = new Gee.ArrayList<string> ();+		d.add ("SpacingClasses");+		return d;+	}+		+}++}diff --git a/libbirdfont/SpacingData.vala b/libbirdfont/SpacingData.valaindex 5d1b4c9..39cff23 100644--- a/libbirdfont/SpacingData.vala+++ b/libbirdfont/SpacingData.vala@@ -69,7 +69,7 @@ public class SpacingData : GLib.Object { 					add_connections (s.next); 				} 			}-+			 			if (s.next == glyph) { 				if (!has_connection (s.first)) { 					add_connections (s.first);diff --git a/libbirdfont/Toolbox.vala b/libbirdfont/Toolbox.valaindex a6d1ff2..075d86f 100644--- a/libbirdfont/Toolbox.vala+++ b/libbirdfont/Toolbox.vala@@ -27,6 +27,7 @@ public class Toolbox : GLib.Object  { 	public static OverviewTools overview_tools; 	public static BackgroundTools background_tools;	 	public static SpacingTools spacing_tools;+	public static SpacingClassTools spacing_class_tools; 	public static FileTools file_tools; 	public static ThemeTools theme_tools; 	@@ -64,6 +65,7 @@ public class Toolbox : GLib.Object  { 		overview_tools = new OverviewTools (); 		background_tools = new BackgroundTools (); 		spacing_tools = new SpacingTools ();+		spacing_class_tools = new SpacingClassTools  (); 		file_tools = new FileTools (); 		theme_tools = new ThemeTools (); 		@@ -74,6 +76,7 @@ public class Toolbox : GLib.Object  { 		tool_sets.add (kerning_tools); 		tool_sets.add (preview_tools); 		tool_sets.add (overview_tools);+		tool_sets.add (spacing_class_tools); 		tool_sets.add (background_tools); 		// the menu has all the file_tools commands, it will not be added here 		tool_sets.add (hidden_tools); // tools without a button@@ -123,6 +126,8 @@ public class Toolbox : GLib.Object  { 			current_set = (ToolCollection) overview_tools; 		} else if (tab_name == "Backgrounds") { 			current_set = (ToolCollection) background_tools;+		} else if (tab_name == "SpacingClasses") {+			current_set = (ToolCollection) spacing_class_tools; 		} else if (tab_name == "Themes") { 			current_set = (ToolCollection) theme_tools; 		} else if (t != null && ((!) t).get_display () is GlyphTab) {

Contact

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