Clone in a terminal:
Commit ea98f7e
Johan Mattsson - 2015-11-19T09:40:24+00:00
ea98f7e559a59f621315cdfef16279d407450f6bjohan.mattsson.m@gmail.com

Merge pull request #11 from novalis/novalis/bounds Add an automatic scaling tool

Changed files (3)

Diff

diff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex da7ca5e..ffad98a 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -102,6 +102,7 @@ public class DrawingTools : ToolCollection  { 	Tool move_layer; 	Tool flip_vertical; 	Tool flip_horizontal;+	Tool full_height_tool; 	 	public ZoomBar zoom_bar; @@ -591,6 +592,14 @@ public class DrawingTools : ToolCollection  { 		reverse_path_tool = new OrientationTool ("reverse_path", t_("Create counter from outline")); 		draw_tool_modifiers.add_tool (reverse_path_tool); +		full_height_tool = new Tool ("full_height", t_("Scale object to font top/baseline"));+		full_height_tool.select_action.connect ((self) => {+				resize_tool.full_height ();+				GlyphCanvas.redraw ();+		});++		draw_tool_modifiers.add_tool (full_height_tool);+ 		// close path 		close_path_tool = new Tool ("close_path", t_("Close path")); 		close_path_tool.select_action.connect ((self) => {@@ -1321,6 +1330,7 @@ public class DrawingTools : ToolCollection  { 		height.set_tool_visibility (false); 		skew.set_tool_visibility (false); 		reverse_path_tool.set_tool_visibility (false);+		full_height_tool.set_tool_visibility (false); 		move_layer.set_tool_visibility (false); 		flip_vertical.set_tool_visibility (false); 		flip_horizontal.set_tool_visibility (false);@@ -1392,6 +1402,8 @@ public class DrawingTools : ToolCollection  { 		move_layer.set_tool_visibility (true); 		flip_vertical.set_tool_visibility (true); 		flip_horizontal.set_tool_visibility (true);++		full_height_tool.set_tool_visibility (true); 	} 	 	public void update_drawing_and_background_tools (Tool current_tool) {diff --git a/libbirdfont/ResizeTool.vala b/libbirdfont/ResizeTool.valaindex 14222d0..23336b4 100644--- a/libbirdfont/ResizeTool.vala+++ b/libbirdfont/ResizeTool.vala@@ -377,6 +377,34 @@ public class ResizeTool : Tool { 		} 	} +	public void full_height () {+		double xc, yc, w, h;+		Glyph glyph = MainWindow.get_current_glyph ();+		Font font = BirdFont.get_current_font ();++		MoveTool.update_boundaries_for_selection ();+		MoveTool.get_selection_box_boundaries (out xc, out yc, out w, out h);++		//compute scale+		double font_height = font.top_position - font.base_line;+		double scale = font_height / h;+		foreach (Path p in glyph.active_paths) {+			p.scale(scale, scale);+		}++		PenTool.reset_stroke ();++		MoveTool.update_boundaries_for_selection ();+		font.touch ();++		MoveTool.get_selection_box_boundaries (out selection_box_center_x,+											   out selection_box_center_y,+											   out selection_box_width,+											   out selection_box_height);++		objects_resized (selection_box_width, selection_box_height);+	}+ 	void get_selection_min (out double x, out double y) { 		Glyph glyph = MainWindow.get_current_glyph (); 		x = double.MAX;diff --git a/resources/icons.bf b/resources/icons.bfindex 5308f6f..f633d73 100644--- a/resources/icons.bf+++ b/resources/icons.bf@@ -638,6 +638,17 @@ GNU Lesser General Public License</copyright> 		</layer> 	</glyph> </collection>+<collection name="full_height">+	<selected id="0"/>+	<glyph id="0" left="-28" right="28">+		<layer name= "Layer" visible="true">+			<path data="B 1.0673867152,64.5511235887 M 2.4423867152,63.1448235887 M 27.5673867152,37.3636235887 M 30.7861367152,34.0511235887 M 26.1923867152,34.0511235887 M 14.8486367152,34.0511235887 M 14.8486367152,20.2386235887 M 25.5048867152,20.2076235887 M 30.0361367152,20.1766235887 M 26.9111367152,16.9266235887 M 2.1298867152,-9.0733764113 M 0.7548867152,-10.5108764113 M -0.6513632848,-9.1046764113 M -26.4951132848,16.6766235887 M -29.7451132848,19.9266235887 M -25.1513632848,20.0206235887 M -15.1201132848,20.1769235887 M -14.9951132848,33.7082235887 M -25.0263632848,33.7082235887 M -29.7138632848,33.7082235887 M -26.4013632848,37.0206235887 M -0.3388632848,63.1456235887 M 1.0673867152,64.5519235887 M 1.0673867152,64.5511235887" />+			<path data="B 1.0361367152,57.9322274474 M -20.3388632848,36.4948274474 M -12.9951132848,36.4948274474 M -11.0576132848,36.4948274474 M -11.0576132848,34.5572274474 M -11.2451132848,17.1510274474 M -11.2764132848,15.2448274474 M -13.1514132848,15.2138274474 M -20.4951632848,15.0888274474 M 0.6923367152,-6.0361725526 M 20.9735867152,15.2451274474 M 12.8798367152,15.2761274474 M 10.9423367152,15.2761274474 M 10.9423367152,17.2136274474 M 10.9423367152,34.9011274474 M 10.9423367152,36.8699274474 M 12.8798367152,36.8699274474 M 21.5673367152,36.8699274474 M 1.0360867152,57.9323274474 M 1.0361367152,57.9322274474" />+			<path data="S 28.0000000000,67.0000000000 L 28.0000000000,64.0000000000 L -28.0000000000,64.0000000000 L -28.0000000000,67.0000000000 L 28.0000000000,67.0000000000" />+			<path data="S 28.0000000000,-10.0000000000 L 28.0000000000,-13.0000000000 L -28.0000000000,-13.0000000000 L -28.0000000000,-10.0000000000 L 28.0000000000,-10.0000000000" />+		</layer>+	</glyph>+</collection> <collection unicode="U+67"> 	<selected id="1"/> 	<glyph id="1" left="-28" right="28">@@ -1660,6 +1671,7 @@ GNU Lesser General Public License</copyright> <ligature sequence="c i r c l e" replacement="circle"/> <ligature sequence="r e s i z e" replacement="resize"/> <ligature sequence="h e i g h t" replacement="height"/>+<ligature sequence="f u l l _ h e i g h t" replacement="full_height"/> <ligature sequence="t r a c k" replacement="track"/> <ligature sequence="w i d t h" replacement="width"/> <ligature sequence="t h e m e" replacement="theme"/>

Contact

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