Clone in a terminal:
Commit 88c2fce
Johan Mattsson - 2016-06-11T10:02:49+00:00
88c2fcede7d946773fe0917213ef4b43189493cdjohan.mattsson.m@gmail.com

Merge ../birdfont-2.x

Changed files (17)

Diff

diff --git a/libbirdfont/AbstractMenu.vala b/libbirdfont/AbstractMenu.valaindex 19c8e3d..39ee6ee 100644--- a/libbirdfont/AbstractMenu.vala+++ b/libbirdfont/AbstractMenu.vala@@ -83,7 +83,7 @@ public class AbstractMenu : GLib.Object { 		 		display = current_display.get_name (); -		if (current_display is Glyph) {+		if (current_display is GlyphTab) { 			display = "Glyph"; 		} 		diff --git a/libbirdfont/ClipTool.vala b/libbirdfont/ClipTool.valaindex 5f9ab14..f3686ad 100644--- a/libbirdfont/ClipTool.vala+++ b/libbirdfont/ClipTool.vala@@ -34,7 +34,7 @@ public class ClipTool : Tool { 		string bf_data; 		string data; 		-		if (fd is Glyph) {+		if (fd is GlyphTab) { 			svg_data = ExportTool.export_selected_paths_to_svg (); 			 			bf_data = export_selected_paths_to_birdfont_clipboard ();@@ -89,7 +89,7 @@ public class ClipTool : Tool { 		double x, y, w, h; 		double dx, dy; 		-		if (fd is Glyph) {+		if (fd is GlyphTab) { 			paste_paths (false); 			 			g.selection_boundaries (out x, out y, out w, out h);@@ -117,7 +117,7 @@ public class ClipTool : Tool { 		// Determine if clipboard contains data in birdfont format. 		is_bf_clipboard = clipboard_data.index_of ("BirdFontClipboard") > -1;  -		if (fd is Glyph) {+		if (fd is GlyphTab) { 			paste_to_glyph (is_bf_clipboard, paste_guide_lines); 		} 		@@ -134,7 +134,7 @@ public class ClipTool : Tool { 		FontDisplay fd = MainWindow.get_current_display (); 		Glyph? destination = null; 		string data;-		return_if_fail (fd is Glyph);+		return_if_fail (fd is GlyphTab); 		 		destination = (Glyph) fd; 		((!)destination).store_undo_state ();diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 0ea8a04..2015ffe 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -685,7 +685,7 @@ public class DrawingTools : ToolCollection  { 		});	 		 		bg_selection.select_action.connect((self) => {-			if (MainWindow.get_current_display () is Glyph) {+			if (MainWindow.get_current_display () is GlyphTab) { 				BackgroundTool.import_background_image (); 			} 		});@@ -1255,9 +1255,11 @@ public class DrawingTools : ToolCollection  { 		// update selelction when the user switches tab 		MainWindow.get_tab_bar ().signal_tab_selected.connect((tab) => { 			Glyph glyph;+			GlyphTab glyph_tab; 			-			if (tab.get_display () is Glyph) {-				glyph = (Glyph) tab.get_display ();+			if (tab.get_display () is GlyphTab) {+				glyph_tab = (GlyphTab) tab.get_display ();+				glyph = glyph_tab.glyphs.get_current (); 				show_bg.set_selected (glyph.get_background_visible ()); 				update_line_selection (glyph); 			}diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex ee9178d..1bdaee2 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -122,7 +122,7 @@ public class Glyph : FontDisplay { 	Line left_line; 	Line right_line; -	/** Cache for Cairo rendering */+	/** Cache for Cairo surface rendering */ 	HashMap<string, Surface> glyph_cache = new HashMap<string, Surface> ();  	public const double CANVAS_MIN = -10000;diff --git a/libbirdfont/GlyphRange.vala b/libbirdfont/GlyphRange.valaindex 3c8448f..fdb5f5f 100644--- a/libbirdfont/GlyphRange.vala+++ b/libbirdfont/GlyphRange.vala@@ -532,7 +532,9 @@ public class GlyphRange { 		uns = unserialize (c); 		 		if (uns.char_count () != 1) {-			warning (@"Expecting a single character got $c");+			// the glyph was not found by its name because it is not in the list of+			// unassigned characters+			return false;  		} 		 		s = uns.get_char ();diff --git a/libbirdfont/GlyphTab.vala b/libbirdfont/GlyphTab.valanew file mode 100644index 0000000..ca8972b--- /dev/null+++ b/libbirdfont/GlyphTab.vala@@ -0,0 +1,155 @@+/*+	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 GlyphTab : FontDisplay {++	public GlyphCollection glyphs;++	public GlyphTab (GlyphCollection glyphs) {+		this.glyphs = glyphs;+	}++	public override string get_name () {+		return glyphs.get_current ().get_name ();+	}++	public override string get_label () {+		return glyphs.get_current ().get_label ();+	}++	public override void close () {+		glyphs.get_current ().close ();+	}++	public override bool has_scrollbar () {+		return glyphs.get_current ().has_scrollbar ();+	}++	public override void update_scrollbar () {+		glyphs.get_current ().update_scrollbar ();+	}++	public override void scroll_to (double percent) {+		glyphs.get_current ().scroll_to (percent);+	}++	public override void draw (WidgetAllocation allocation, Context cr) {+		glyphs.get_current ().draw (allocation, cr);+	}++	public override void selected_canvas () {+		glyphs.get_current ().selected_canvas ();+	}++	public override void key_press (uint keyval) {+		glyphs.get_current ().key_press (keyval);+	}++	public override void key_release (uint keyval) {+		glyphs.get_current ().key_release (keyval);+	}++	public override void motion_notify (double x, double y) {+		glyphs.get_current ().motion_notify (x, y);+	}++	public override void button_release (int button, double x, double y) {+		glyphs.get_current ().button_release (button, x, y);+	}++	public override void button_press (uint button, double x, double y) {+		glyphs.get_current ().button_press (button, x, y);+	}++	public override void double_click (uint button, double ex, double ey) {+		glyphs.get_current ().double_click (button, ex, ey);	+	}++	public override void magnify (double magnification) {+		glyphs.get_current ().magnify (magnification);+	}++	public override void tap_down (int finger, int x, int y) {+		glyphs.get_current ().tap_down (finger, x, y);+	}++	public override void tap_up (int finger, int x, int y) {+		glyphs.get_current ().tap_up (finger, x, y);+	}++	public override void tap_move (int finger, int x, int y) {+		glyphs.get_current ().tap_move (finger, x, y);+	}++	public override void zoom_in () {+		glyphs.get_current ().zoom_in ();+	}++	public override void zoom_out () {+		glyphs.get_current ().zoom_out ();+	}++	public override void zoom_max () {+		glyphs.get_current ().zoom_max ();+	}++	public override void zoom_min () {+		glyphs.get_current ().zoom_min ();+	}++	public override void move_view (double x, double y) {+		glyphs.get_current ().move_view (x, y);	+	}++	public override void reset_zoom () {+		glyphs.get_current ().reset_zoom ();+	}++	public override void store_current_view () {+		glyphs.get_current ().store_current_view ();+	}++	public override void restore_last_view () {+		glyphs.get_current ().restore_last_view ();+	}++	public override void next_view () {+		glyphs.get_current ().next_view ();+	}++	public override void scroll_wheel (double x, double y,+		double pixeldelta_x,  double pixeldelta_y) {+			glyphs.get_current ().scroll_wheel (x, y, pixeldelta_x, pixeldelta_y);+	}++	public override void undo () {+		glyphs.get_current ().undo ();+	}++	public override void redo () {+		glyphs.get_current ().redo ();+	}++	/** returns false if bindings to a single key works in the display. */+	public override bool needs_modifier () {+		return glyphs.get_current ().needs_modifier ();+	}+}++}diff --git a/libbirdfont/KerningClasses.vala b/libbirdfont/KerningClasses.valaindex 4198a8c..77f257d 100644--- a/libbirdfont/KerningClasses.vala+++ b/libbirdfont/KerningClasses.vala@@ -80,6 +80,27 @@ public class KerningClasses : GLib.Object { 		} 	} +	/** Copy kerning pairs for newly created spacing classes. */+	public void copy_single_kerning_pairs (string from_spacing_class, string to_spacing_class) {+		double? kerning;+		+		foreach (string left in single_kerning_letters_left) {	+			kerning = get_kerning_for_single_glyphs (left, from_spacing_class);+			+			if (kerning != null) {+				set_kerning_for_single_glyphs (left, to_spacing_class, (!) kerning);+			}+		}++		foreach (string right in single_kerning_letters_right) {	+			kerning = get_kerning_for_single_glyphs (from_spacing_class, right);+			+			if (kerning != null) {+				set_kerning_for_single_glyphs (to_spacing_class, right, (!) kerning);+			}+		}		+	}+ 	/** Class based gpos kerning. */ 	public double get_kerning_for_pair (string a, string b, GlyphRange? gr_left, GlyphRange? gr_right) { 		double k = 0;@@ -127,34 +148,19 @@ public class KerningClasses : GLib.Object { 		return 0; 	} -	public void update_space_class (string c) {-		double? k;-		-		foreach (string l in single_kerning_letters_left) {	-			k = get_kerning_for_single_glyphs (l, c);-			-			if (k != null) {-				set_kerning_for_single_glyphs (l, c, (!) k);-			}-		}--		foreach (string r in single_kerning_letters_right) {	-			k = get_kerning_for_single_glyphs (c, r);-			-			if (k != null) {-				set_kerning_for_single_glyphs (c, r, (!) k);-			}-		}		-	}- 	public double? get_kerning_for_single_glyphs (string first, string next) { 		double? k = null;+		double? kerning = null; 		string left = GlyphRange.serialize (first); 		string right = GlyphRange.serialize (next);  		foreach (string l in get_spacing_class (left)) { 			foreach (string r in get_spacing_class (right)) {-				k = single_kerning.get (@"$l - $r");+				kerning = single_kerning.get (@"$l - $r");+				+				if (kerning != null) {+					k = kerning;+				}				 			} 		} 		diff --git a/libbirdfont/MainWindow.vala b/libbirdfont/MainWindow.valaindex c4f028a..bf0613a 100644--- a/libbirdfont/MainWindow.vala+++ b/libbirdfont/MainWindow.vala@@ -284,10 +284,12 @@ public class MainWindow : GLib.Object { 
 	/** Reaload all paths and help lines from disk. */
 	public static void clear_glyph_cache () {
-		Glyph g;
+		Glyph g;+		GlyphTab tab;
 		foreach (Tab t in get_tab_bar ().tabs) {
-			if (t.get_display () is Glyph) {
-				g = (Glyph) t.get_display ();
+			if (t.get_display () is GlyphTab) {+				tab = (GlyphTab) t.get_display ();
+				g = tab.glyphs.get_current ();
 				g.add_help_lines ();
 			}
 		}
diff --git a/libbirdfont/OverView.vala b/libbirdfont/OverView.valaindex a2cc1da..a6ffa3e 100644--- a/libbirdfont/OverView.vala+++ b/libbirdfont/OverView.vala@@ -96,10 +96,12 @@ public class OverView : FontDisplay { 				bool selected = tabs.select_char (n); 				GlyphCanvas canvas; 				Glyph g = glyph_collection.get_current (); +				GlyphTab glyph_tab;				 				 				if (!selected) {+					glyph_tab = new GlyphTab (glyph_collection); 					canvas = MainWindow.get_glyph_canvas ();-					tabs.add_tab (g, true, glyph_collection);+					tabs.add_tab (glyph_tab, true, glyph_collection); 					canvas.set_current_glyph_collection (glyph_collection); 					set_initial_zoom (); 					PenTool.update_orientation ();@@ -184,6 +186,7 @@ public class OverView : FontDisplay { 		Glyph glyph; 		GlyphCollection glyph_collection; 		GlyphCanvas canvas;+		GlyphTab glyph_tab;  		 		glyph_collection = MainWindow.get_current_glyph_collection (); 		name.append_unichar (character);@@ -191,10 +194,10 @@ public class OverView : FontDisplay { 				 		if (!selected) { 			glyph_collection = add_character_to_font (character);-			+			glyph_tab = new GlyphTab (glyph_collection); 			glyph = glyph_collection.get_current (); 			glyph.layers.add_layer (new Layer ());-			tabs.add_tab (glyph, true, glyph_collection);+			tabs.add_tab (glyph_tab, true, glyph_collection); 			 			selected_items.add (glyph_collection); 			diff --git a/libbirdfont/OverViewItem.vala b/libbirdfont/OverViewItem.valaindex 549d969..fc871a4 100644--- a/libbirdfont/OverViewItem.vala+++ b/libbirdfont/OverViewItem.vala@@ -271,8 +271,8 @@ public class OverViewItem : GLib.Object { 		cr.set_line_width (1); 		cr.stroke (); 		cr.restore ();-	-		draw_thumbnail (cr, x, y + height);	+		+		draw_thumbnail (cr, x, y + height); 		draw_caption (cr); 		draw_menu (cr); 	}diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex 337d048..cc4a695 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -1471,7 +1471,7 @@ public class Path : GLib.Object { 		 		if (steps == -1) { 			steps = (int) (10 * get_length_from (start, stop));-		}+		}	 		 		if (right == PointType.DOUBLE_CURVE || left == PointType.DOUBLE_CURVE) { 			return all_of_double (start.x, start.y, start.get_right_handle ().x, start.get_right_handle ().y, stop.get_left_handle ().x, stop.get_left_handle ().y, stop.x, stop.y, iter, steps, min_t, max_t);diff --git a/libbirdfont/PointConverter.vala b/libbirdfont/PointConverter.valaindex 9c6edf2..88951d9 100644--- a/libbirdfont/PointConverter.vala+++ b/libbirdfont/PointConverter.vala@@ -1,5 +1,5 @@ /*-	Copyright (C) 2014 Johan Mattsson+	Copyright (C) 2014 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 @@ -50,6 +50,8 @@ public class PointConverter { 			} 		} 		+		+		 		if (!original_path.is_open ()) { 			if (quadratic_path.get_last_point ().get_right_handle ().type == PointType.CUBIC) { 				PenTool.convert_point_segment_type (quadratic_path.get_last_point (),@@ -93,8 +95,9 @@ public class PointConverter { 			quadratic_segment_start = segment_start.copy (); 			quadratic_segment_stop = segment_stop.copy (); 			-			PenTool.convert_point_segment_type (quadratic_segment_start, quadratic_segment_stop, PointType.DOUBLE_CURVE);-			+			PenTool.convert_point_segment_type (quadratic_segment_start, quadratic_segment_stop, PointType.DOUBLE_CURVE);			++			// add new points to estimate path 			distance = 0; 			e = new EditPoint (); 			if (segment_start.get_right_handle ().is_line () @@ -124,7 +127,7 @@ public class PointConverter { 			out double distance, out EditPoint new_point, out double step) { 		double max_d; 		double min_d;-		int steps = (int) (1.6 * Path.get_length_from (a0, a1));+		int steps; 		double x_out, y_out; 		double step_out; diff --git a/libbirdfont/SpacingClass.vala b/libbirdfont/SpacingClass.valaindex 43009df..83c197d 100644--- a/libbirdfont/SpacingClass.vala+++ b/libbirdfont/SpacingClass.vala@@ -56,12 +56,11 @@ public class SpacingClass : GLib.Object  { 			} else { 				next = v.dup (); 			}-			-			updated (this); 		}); 		 		listener.signal_submit.connect (() => { 			TabContent.hide_text_input ();+			updated (this); 		}); 		 		TabContent.show_text_input (listener);diff --git a/libbirdfont/SpacingData.vala b/libbirdfont/SpacingData.valaindex 50fd36d..5d1b4c9 100644--- a/libbirdfont/SpacingData.vala+++ b/libbirdfont/SpacingData.vala@@ -83,11 +83,11 @@ public class SpacingData : GLib.Object { 	}  	public void add_class (string first, string next) {-		SpacingClass s = new SpacingClass (first, next);-		s.updated.connect (update_all_rows);-		s.updated.connect (update_kerning);-		classes.add (s);-		update_kerning (s);+		SpacingClass spacing_class = new SpacingClass (first, next);+		spacing_class.updated.connect (update_all_rows);+		spacing_class.updated.connect (update_kerning);+		classes.add (spacing_class);+		update_kerning (spacing_class); 	}  	void update_all_rows (SpacingClass s) {@@ -103,14 +103,18 @@ public class SpacingData : GLib.Object { 			return; 		} -		kerning_classes.update_space_class (s.next);+		if (s.next == "" || s.first == "") {+			return;+		}+		+		kerning_classes.copy_single_kerning_pairs (s.first, s.next);+		 		g = font.get_glyph_collection (s.next); 		if (g != null) { 			gc = (!) g; 			gc.get_current ().update_spacing_class (); 		} -		kerning_classes.update_space_class (s.first); 		g = font.get_glyph_collection (s.first); 		if (g != null) { 			gc = (!) g;diff --git a/libbirdfont/TabContent.vala b/libbirdfont/TabContent.valaindex f45a1af..89b0789 100644--- a/libbirdfont/TabContent.vala+++ b/libbirdfont/TabContent.vala@@ -439,7 +439,7 @@ public class TabContent : GLib.Object { 		TabContent.key_release (Key.LOGO_LEFT); 		TabContent.key_release (Key.LOGO_RIGHT); -		if (MainWindow.get_current_display () is Glyph) {+		if (MainWindow.get_current_display () is GlyphTab) { 			TabContent.key_release ((uint) ' '); 		} 	}diff --git a/libbirdfont/Toolbox.vala b/libbirdfont/Toolbox.valaindex 0084a50..bbe7538 100644--- a/libbirdfont/Toolbox.vala+++ b/libbirdfont/Toolbox.vala@@ -125,7 +125,7 @@ public class Toolbox : GLib.Object  { 			current_set = (ToolCollection) background_tools; 		} else if (tab_name == "Themes") { 			current_set = (ToolCollection) theme_tools;-		} else if (t != null && ((!) t).get_display () is Glyph) {+		} else if (t != null && ((!) t).get_display () is GlyphTab) { 			current_set = (ToolCollection) drawing_tools; 		} else { 			current_set = (ToolCollection) file_tools;diff --git a/libbirdfont/VersionList.vala b/libbirdfont/VersionList.valaindex 926d64e..14779cf 100644--- a/libbirdfont/VersionList.vala+++ b/libbirdfont/VersionList.vala@@ -234,7 +234,7 @@ public class VersionList : GLib.Object {  			tab = (!) tn; -			if (! (tab.get_display () is Glyph)) {+			if (! (tab.get_display () is GlyphTab)) { 				continue;  			} 			

Contact

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