Clone in a terminal:
Commit 90f27fb
Johan Mattsson - 2014-03-21T01:16:11+00:00
90f27fbe53040295d7742f9935791488585c99a5johan.mattsson.m@gmail.com

Adjust kerning tab to font height

Changed files (7)

Diff

diff --git a/NEWS b/NEWSindex 882c686..94d9509 100644--- a/NEWS+++ b/NEWS@@ -1,6 +1,6 @@ birdfont (0.35) stable; -  * A new tool for drawing shapes with the mouse on free hand+  * A new tool for drawing freehand shapes with the mouse   * Bug fixes related to conversion from SVG to TTF   * Fixes crash bug in SVG import code   diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 1c5cb5d..afba2a2 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -580,15 +580,15 @@ public class DrawingTools : ToolCollection  { 		stroke_width.set_min (0.002); 		stroke_width.set_value_round (1); -		if (Preferences.get ("stroke_width") != "") {-			stroke_width.set_value (Preferences.get ("stroke_width"));+		if (Preferences.get ("stroke_width_for_open_paths") != "") {+			stroke_width.set_value (Preferences.get ("stroke_width_for_open_paths")); 		}  		stroke_width.new_value_action.connect ((self) => { 			Glyph g = MainWindow.get_current_glyph (); 			Path.stroke_width = stroke_width.get_value (); 			g.redraw_area (0, 0, g.allocation.width, g.allocation.height);-			Preferences.set ("stroke_width", stroke_width.get_display_value ());+			Preferences.set ("stroke_width_for_open_paths", stroke_width.get_display_value ()); 			MainWindow.get_toolbox ().redraw ((int) stroke_width.x, (int) stroke_width.y, 70, 70); 		}); 		diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 67f2066..004dd16 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -493,13 +493,9 @@ public class Glyph : FontDisplay { 		return Svg.to_svg_glyph (this); 	} 	-	public int get_height () -		requires (vertical_help_lines.length () >= 2)-	{-		unowned List<Line> a = horizontal_help_lines.first ();-		unowned List<Line> b = horizontal_help_lines.last ();-		-		return (int) Math.fabs (a.data.pos - b.data.pos); +	public int get_height () {+		Font f = BirdFont.get_current_font ();+		return (int) Math.fabs (f.top_limit - f.bottom_limit);  	} 	 	public double get_width () {diff --git a/libbirdfont/KerningDisplay.vala b/libbirdfont/KerningDisplay.valaindex 34cd311..67a512a 100644--- a/libbirdfont/KerningDisplay.vala+++ b/libbirdfont/KerningDisplay.vala@@ -81,20 +81,29 @@ public class KerningDisplay : FontDisplay {  		cr.set_font_size (14); 		cr.move_to (30, 80);-		cr.show_text (line3);-							+		cr.show_text (line3);				 		cr.restore (); 	} 	+	double get_row_height () {+		Font font = BirdFont.get_current_font ();+		return font.top_limit - font.bottom_limit;+	}+	 	public void draw_kerning_pairs (WidgetAllocation allocation, Context cr) { 		Glyph glyph; 		double x, y, w, kern, alpha; 		double x2;+		double caret_y; 		int i, wi; 		Glyph? prev; 		GlyphSequence word_with_ligatures; 		GlyphRange? gr_left, gr_right; 		bool first_row = true;+		double row_height;+		Font font;+		+		font = BirdFont.get_current_font (); 		i = 0; 		 		// bg color@@ -103,9 +112,13 @@ public class KerningDisplay : FontDisplay { 		cr.rectangle (0, 0, allocation.width, allocation.height); 		cr.fill (); 		cr.restore ();+		+		glyph = MainWindow.get_current_glyph ();+		+		row_height = get_row_height (); 	 		alpha = 1;-		y = 100;+		y = get_row_height () + font.base_line + 20; 		x = 20; 		w = 0; 		prev = null;@@ -140,7 +153,11 @@ public class KerningDisplay : FontDisplay { 				} else { 					alpha = 0; 					glyph = (!) g;+					+					// TODO: set font size+					// cr.scale (KerningTools.font_size, KerningTools.font_size); 					Svg.draw_svg_path (cr, glyph.get_svg_data (), x + kern, y);+					 					w = glyph.get_width (); 				} @@ -194,11 +211,12 @@ public class KerningDisplay : FontDisplay { 			 			// draw caret 			if (first_row) {-				x2 = x + kern / 2.0;+				x2 = x;+				caret_y = get_row_height () + font.base_line + 20; 				cr.save (); 				cr.set_source_rgba (0, 0, 0, 0.5);-				cr.move_to (x2, 20);-				cr.line_to (x2, 120);+				cr.move_to (x2, caret_y + 20);+				cr.line_to (x2, 20); 				cr.stroke (); 				cr.restore (); 			}@@ -207,7 +225,7 @@ public class KerningDisplay : FontDisplay { 				row.remove (word); 			} 						-			y += MainWindow.get_current_glyph ().get_height () + 20;+			y += row_height + 20; 			x = 20; 			first_row = false;	 		}diff --git a/libbirdfont/KerningTools.vala b/libbirdfont/KerningTools.valaindex c63163e..beb7ef3 100644--- a/libbirdfont/KerningTools.vala+++ b/libbirdfont/KerningTools.vala@@ -22,6 +22,8 @@ public class KerningTools : ToolCollection  { 	public static int next_class = 0; 	public static Expander classes; 	+	public static double font_size = 1;+	 	public KerningTools () { 		init (); 	}@@ -43,6 +45,26 @@ public class KerningTools : ToolCollection  { 			d.set_kerning_by_text (); 		}); 		kerning_tools.add_tool (text_kerning);++		SpinButton font_size = new SpinButton ("kerning_font_size", t_("Font size "));++		font_size.set_max (9);+		font_size.set_min (0.002);+		font_size.set_value_round (1);++		if (Preferences.get ("kerning_font_size_settings") != "") {+			font_size.set_value (Preferences.get ("kerning_font_size_settings"));+		}++		font_size.new_value_action.connect ((self) => {+			Glyph g = MainWindow.get_current_glyph ();+			KerningTools.font_size = font_size.get_value ();+			g.update_view ();+			Preferences.set ("kerning_font_size_settings", font_size.get_display_value ());+		});+		+		// TODO: add font size+		// kerning_tools.add_tool (font_size); 		 		kerning_tools.set_persistent (false); 		kerning_tools.set_unique (false);diff --git a/libbirdfont/OpenFontFormat/Kern.vala b/libbirdfont/OpenFontFormat/Kern.valaindex cd9bb6e..6fc1c35 100644--- a/libbirdfont/OpenFontFormat/Kern.vala+++ b/libbirdfont/OpenFontFormat/Kern.vala@@ -145,7 +145,7 @@ public class KernTable : Table { 			 			try { 				// n_pairs is used to truncate this table to prevent buffer overflow-				if (n_pairs > i++) {+				if (i++ < n_pairs) { 					gid1 = (uint16) glyf_table.get_gid (left); 					gid2 = (uint16) glyf_table.get_gid (right); 					diff --git a/libbirdfont/SpinButton.vala b/libbirdfont/SpinButton.valaindex 624f4c7..d9ed9c4 100644--- a/libbirdfont/SpinButton.vala+++ b/libbirdfont/SpinButton.vala@@ -45,16 +45,18 @@ public class SpinButton : Tool { 		panel_press_action.connect ((selected, button, tx, ty) => { 			double py = Math.fabs (y - ty); 			int n = 0;-+			+			if (button == 3) {+				set_from_text ();+				n = 0;+			}+				 			if (is_selected ()) { 				if (button == 1) { 					n = 1; 				} else if (button == 2) { 					n = 10;-				} else if (button == 3) {-					set_from_text ();-					n = 0;-				}+				}  					 				for (int i = 0; i < n; i++) { 					if (py < 9) increase ();@@ -70,6 +72,8 @@ public class SpinButton : Tool { 			if (button == 1) { 				set_selected (true); 			}+			+			redraw (); 		});  		panel_move_action.connect ((selected, button, tx, ty) => {@@ -91,7 +95,7 @@ public class SpinButton : Tool { 					set_int_value (@"$new_value"); 				} 				-				Toolbox.redraw_tool_box ();+				redraw (); 			} 			 			return value_from_motion;@@ -103,6 +107,8 @@ public class SpinButton : Tool { 			if (button == 1) { 				set_selected (false); 			}+			+			redraw (); 		}); 		 		scroll_wheel_up_action.connect ((selected) => {@@ -141,13 +147,14 @@ public class SpinButton : Tool { 				set_int_value (@"$new_value"); 			} 			-			Toolbox.redraw_tool_box ();+			redraw (); 		}); 		 		listener.signal_submit.connect (() => { 			MainWindow.native_window.hide_text_input ();+			redraw (); 		});-		+ 		MainWindow.native_window.set_text_listener (listener); 	} 	@@ -176,6 +183,7 @@ public class SpinButton : Tool { 		}  		new_value_action (this);+		redraw (); 	}  	public void decrease () {@@ -191,6 +199,7 @@ public class SpinButton : Tool { 		} 				 		new_value_action (this);+		redraw (); 	}  	public void set_int_value (string new_value) {@@ -206,6 +215,7 @@ public class SpinButton : Tool { 		milli = parse (v.substring (v.index_of_nth_char (3), 1)); 		 		new_value_action (this);+		redraw (); 	}  	int8 parse (string s) {@@ -250,6 +260,8 @@ public class SpinButton : Tool { 		if (emit_signal) { 			new_value_action (this); 		}+		+		redraw (); 	}  	public void set_value_round (double v, bool check_boundaries = true, bool emit_signal = true) {@@ -296,6 +308,10 @@ public class SpinButton : Tool { 		 		cr.restore (); 	}+	+	public void redraw () {+		 MainWindow.get_toolbox ().redraw ((int) x, (int) y, 70, 70);+	} }  }

Contact

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