Clone in a terminal:
Commit 54e7be1
Johan Mattsson - 2013-09-25T09:54:48+00:00
54e7be17c8adbf00b9b45d22af2e3cdfd5deac22johan.mattsson.m@gmail.com

1024 unts per em and a tool for moving points

Changed files (9)

Diff

diff --git a/graphics/tools_and_buttons.svg b/graphics/tools_and_buttons.svgindex 2e82895..f8a07b1 100644--- a/graphics/tools_and_buttons.svg+++ b/graphics/tools_and_buttons.svg@@ -152,6 +152,58 @@        y1="316.79437"        x2="608.64221"        y2="290.27783" />+    <linearGradient+       inkscape:collect="always"+       xlink:href="#linearGradient3761-1-3-7"+       id="linearGradient4027-9"+       gradientUnits="userSpaceOnUse"+       gradientTransform="matrix(1.1095097,0,0,0.99800197,-656.63464,-283.00582)"+       x1="608.99573"+       y1="316.79437"+       x2="608.64221"+       y2="290.27783" />+    <linearGradient+       id="linearGradient3761-1-3-7">+      <stop+         style="stop-color:#eeeded;stop-opacity:1"+         offset="0"+         id="stop3763-4-4-0" />+      <stop+         style="stop-color:#ffffff;stop-opacity:1;"+         offset="1"+         id="stop3765-1-1-9" />+    </linearGradient>+    <linearGradient+       y2="290.27783"+       x2="608.64221"+       y1="316.79437"+       x1="608.99573"+       gradientTransform="matrix(1.1095097,0,0,0.99800197,-621.96502,-232.68482)"+       gradientUnits="userSpaceOnUse"+       id="linearGradient4107"+       xlink:href="#linearGradient3761-1-3-7"+       inkscape:collect="always" />+    <linearGradient+       inkscape:collect="always"+       xlink:href="#linearGradient3761-1-3-5"+       id="linearGradient4027-1"+       gradientUnits="userSpaceOnUse"+       gradientTransform="matrix(1.1095097,0,0,0.99800197,-656.63464,-283.00582)"+       x1="608.99573"+       y1="316.79437"+       x2="608.64221"+       y2="290.27783" />+    <linearGradient+       id="linearGradient3761-1-3-5">+      <stop+         style="stop-color:#eeeded;stop-opacity:1"+         offset="0"+         id="stop3763-4-4-1" />+      <stop+         style="stop-color:#ffffff;stop-opacity:1;"+         offset="1"+         id="stop3765-1-1-5" />+    </linearGradient>   </defs>   <sodipodi:namedview      id="base"@@ -160,16 +212,16 @@      borderopacity="1.0"      inkscape:pageopacity="0.0"      inkscape:pageshadow="2"-     inkscape:zoom="0.37109375"-     inkscape:cx="152.68141"-     inkscape:cy="694.23086"+     inkscape:zoom="0.99769441"+     inkscape:cx="-199.11977"+     inkscape:cy="661.41669"      inkscape:current-layer="layer1"      inkscape:document-units="px"      showgrid="false"      inkscape:window-width="901"      inkscape:window-height="481"-     inkscape:window-x="84"-     inkscape:window-y="28"+     inkscape:window-x="317"+     inkscape:window-y="231"      inkscape:window-maximized="0"      showguides="true"      inkscape:guide-bbox="true" />@@ -181,7 +233,7 @@         <dc:format>image/svg+xml</dc:format>         <dc:type            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />-        <dc:title></dc:title>+        <dc:title />       </cc:Work>     </rdf:RDF>   </metadata>@@ -207,5 +259,37 @@        inkscape:export-filename="/home/johan/birdfont/icons/tool_button_deselected.png"        inkscape:export-xdpi="90"        inkscape:export-ydpi="90" />+    <path+       style="fill:#e6e6e6;fill-opacity:1;stroke:#000000;stroke-width:0.80317229px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.7716895"+       d="m 12.400148,47.659952 12.215588,10.46124 -4.417338,0.534243 -1.382916,4.210594 z"+       id="path3320"+       inkscape:connector-curvature="0"+       sodipodi:nodetypes="ccccc"+       inkscape:export-filename="/home/johan/birdfont/icons/point_tool.png"+       inkscape:export-xdpi="90"+       inkscape:export-ydpi="90" />+    <rect+       style="fill:#1f1e1f;fill-opacity:1;stroke:none"+       id="rect3030"+       width="40"+       height="40"+       x="-0.32119197"+       y="78.067871" />+    <rect+       style="fill:#928f92;fill-opacity:1;stroke:none"+       id="rect3030-1"+       width="40"+       height="40"+       x="39.581127"+       y="78.226822" />+    <path+       style="fill:#928f92;fill-opacity:1;stroke:#928f92;stroke-width:0.80317229000000001px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"+       d="m 12.892206,91.396962 12.215588,10.461238 -4.417338,0.53424 -1.382916,4.2106 z"+       id="path3320-7"+       inkscape:connector-curvature="0"+       sodipodi:nodetypes="ccccc"+       inkscape:export-filename="/home/johan/birdfont/icons/point_tool.png"+       inkscape:export-xdpi="90"+       inkscape:export-ydpi="90" />   </g> </svg>diff --git a/icons/point_tool.png b/icons/point_tool.pngnew file mode 100644index 0000000..731325aBinary files /dev/null and b/icons/point_tool.png differdiff --git a/libbirdfont/DrawingTools.vala b/libbirdfont/DrawingTools.valaindex 2187dd0..224ba52 100644--- a/libbirdfont/DrawingTools.vala+++ b/libbirdfont/DrawingTools.vala@@ -64,7 +64,10 @@ public class DrawingTools : ToolCollection  { 		// Draw tools 		PenTool pen_tool = new PenTool ("pen_tool"); 		draw_tools.add_tool (pen_tool);-	++		PointTool point_tool = new PointTool ("point_tool");+		draw_tools.add_tool (point_tool);+ 		ZoomTool zoom_tool = new ZoomTool ("zoom_tool"); 		draw_tools.add_tool (zoom_tool); diff --git a/libbirdfont/OpenFontFormat/GlyfTable.vala b/libbirdfont/OpenFontFormat/GlyfTable.valaindex 50f0bef..9dd01c1 100644--- a/libbirdfont/OpenFontFormat/GlyfTable.vala+++ b/libbirdfont/OpenFontFormat/GlyfTable.vala@@ -44,7 +44,7 @@ class GlyfTable : Table { 	// a list of glyphs sorted in the order we expect to find them in a 	// ttf font. notdef is the firs glyph followed by null and nonmarkingreturn. 	// after that will all assigned glyphs appear in sorted (unicode) order, all -	// remaining unassigned glyphs will be added in the last part of the file.	+	// remaining unassigned glyphs will be added in the last section of the file.	 	public List<Glyph> glyphs; 	 	uint16 max_points = 0;diff --git a/libbirdfont/OpenFontFormat/HeadTable.vala b/libbirdfont/OpenFontFormat/HeadTable.valaindex f66d9d2..04e1154 100644--- a/libbirdfont/OpenFontFormat/HeadTable.vala+++ b/libbirdfont/OpenFontFormat/HeadTable.vala@@ -57,7 +57,7 @@ class HeadTable : Table { 	 	/** Set default value for unit. */ 	public static void init () {-		units_per_em = 1000;+		units_per_em = 1024; // FIXME: 		UNITS = 10 * (units_per_em / 1000); 	} 	diff --git a/libbirdfont/OpenFontFormat/Os2Table.vala b/libbirdfont/OpenFontFormat/Os2Table.valaindex f379fa6..d4862ce 100644--- a/libbirdfont/OpenFontFormat/Os2Table.vala+++ b/libbirdfont/OpenFontFormat/Os2Table.vala@@ -80,7 +80,7 @@ class Os2Table : Table { 		fd.add_u32 (0); // ulUnicodeRange3 Bits 64-95 		fd.add_u32 (0); // ulUnicodeRange4 Bits 96-127 -		fd.add_tag ("----"); // VendID+		fd.add_tag ("Vend"); // VendID 		 		 // fsSelection (1 for italic 0 for upright) @@ -106,7 +106,7 @@ class Os2Table : Table { 		 		fd.add_16 (ascender); // sTypoAscender 		fd.add_16 (descender); // sTypoDescender-		fd.add_16 (3); // sTypoLineGap+		fd.add_16 (10); // sTypoLineGap  		fd.add_u16 (ascender); // usWinAscent 		fd.add_u16 (-descender); // usWinDescent (unassigned, not like sTypoDescender)@@ -122,7 +122,7 @@ class Os2Table : Table { 		fd.add_16 (0x0020); // usBreakChar also known as space 		 		// FIXME: calculate these values-		fd.add_16 (2); // usMaxContext+		fd.add_16 (2); // usMaxContext (two becase it has kernings but not ligatures).  		// padding 		fd.pad ();diff --git a/libbirdfont/PenTool.vala b/libbirdfont/PenTool.valaindex 94894ff..2bd3cca 100644--- a/libbirdfont/PenTool.vala+++ b/libbirdfont/PenTool.vala@@ -17,6 +17,7 @@ using Cairo;  namespace BirdFont { +/** Create new points. */ public class PenTool : Tool {  	private static const double CONTACT_SURFACE = 20;@@ -400,6 +401,16 @@ public class PenTool : Tool { 		 		return_if_fail (g != null); +		if (double_click) {+			glyph.insert_new_point_on_path (x, y);+			return;+		}+		+		if (button == 1) {+			add_point_event (x, y);+			return;+		}+ 		if (button == 2) { 			if (glyph.is_open ()) { 				force_direction ();@@ -407,23 +418,32 @@ public class PenTool : Tool { 			} else { 				glyph.open_path (); 			}-			-			return;-		}--		if (double_click) {-			glyph.insert_new_point_on_path (x, y); 			return; 		} 		-		// add new point-		if (button == 3 || (KeyBindings.modifier & LOGO) > 0) {-			remove_all_selected_points ();-			new_point_action (x, y);-			glyph.store_undo_state ();+		if (button == 3) {+			move_point_event (x, y); 			return; 		}-				+	}++	public void add_point_event (int x, int y) {+		Glyph? g = MainWindow.get_current_glyph ();+		Glyph glyph = (!) g;+		+		return_if_fail (g != null);+		+		remove_all_selected_points ();+		new_point_action (x, y);+		glyph.store_undo_state ();+	}+		+	public void move_point_event (int x, int y) {+		Glyph? g = MainWindow.get_current_glyph ();+		Glyph glyph = (!) g;+		+		return_if_fail (g != null);+		 		control_point_event (x, y); 		curve_corner_event (x, y); 		diff --git a/libbirdfont/PointTool.vala b/libbirdfont/PointTool.valanew file mode 100644index 0000000..e617f38--- /dev/null+++ b/libbirdfont/PointTool.vala@@ -0,0 +1,85 @@+/*+    Copyright (C) 2013 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 Math;+using Cairo;++namespace BirdFont {++/** Move control points. */+public class PointTool : Tool {+	+	public PointTool (string name) {+		base (name, t_ ("Move control points"), '.', CTRL);++		select_action.connect ((self) => {+		});++		deselect_action.connect ((self) => {+		});+		+		press_action.connect ((self, b, x, y) => {+			Tool p = pen ();+			if (b == 1) {+				p.press_action (p, 3, x, y);+			} else if (b == 2) {+				p.press_action (p, 2, x, y);+			} else if (b == 3) {+				p.press_action (p, 1, x, y);+			}+		});+		+		double_click_action.connect ((self, b, x, y) => {+			Tool p = pen ();+			p.double_click_action (p, b, x, y);+		});++		release_action.connect ((self, b, x, y) => {+			Tool p = pen ();+			if (b == 1) {+				p.release_action (p, 3, x, y);+			} else if (b == 2) {+				p.release_action (p, 2, x, y);+			} else if (b == 3) {+				p.release_action (p, 1, x, y);+			}+		});++		move_action.connect ((self, x, y) => {+			Tool p = pen ();+			p.move_action (p, x, y);+		});+		+		key_press_action.connect ((self, keyval) => {+			Tool p = pen ();+			p.key_press_action (p, keyval);+		});+		+		key_release_action.connect ((self, keyval) => {+			Tool p = pen ();+			p.key_release_action (p, keyval);+		});+		+		draw_action.connect ((tool, cairo_context, glyph) => {+			Tool p = pen ();+			p.draw_action (p, cairo_context, glyph);+		});+	}+	+	private static Tool pen () {+		return MainWindow.get_toolbox ().get_tool ("pen_tool");+	}+}++}diff --git a/scripts/Application.mk b/scripts/Application.mkindex 6f33c8a..f05229c 100644--- a/scripts/Application.mk+++ b/scripts/Application.mk@@ -1 +1 @@-APP_ABI := ALL+APP_ABI := armeabi armeabi-v7a

Contact

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