Clone in a terminal:
Commit d1781dc
Johan Mattsson - 2016-06-12T11:08:17+00:00
d1781dc05cffcdb793d25a8edc833696177075aajohan.mattsson.m@gmail.com

Revert "Store error tolerance for conversion from cubic to quadratic paths" This reverts commit 2e10c9e35c3160b11abe14f7aaf87777d4b90af6.

Changed files (8)

Diff

diff --git a/libbirdfont/BirdFontFile.vala b/libbirdfont/BirdFontFile.valaindex 1c664e3..485b2cf 100644--- a/libbirdfont/BirdFontFile.vala+++ b/libbirdfont/BirdFontFile.vala@@ -24,7 +24,7 @@ class BirdFontFile : GLib.Object { 	Font font; 	 	public static const int FORMAT_MAJOR = 2;-	public static const int FORMAT_MINOR = 2;+	public static const int FORMAT_MINOR = 1; 	 	public static const int MIN_FORMAT_MAJOR = 0; 	public static const int MIN_FORMAT_MINOR = 0;@@ -341,8 +341,7 @@ class BirdFontFile : GLib.Object { 			os.put_string ("\n"); 		} 		-		os.put_string (@"<background scale=\"$(font.background_scale)\" />\n");-		os.put_string (@"<conversion tolerance=\"$(font.tolerance)\" />\n");	+		os.put_string (@"<background scale=\"$(font.background_scale)\" />\n");	 	}  	public void write_description (DataOutputStream os) throws GLib.Error {@@ -745,10 +744,6 @@ class BirdFontFile : GLib.Object { 				parse_background (t); 			} -			if (t.get_name () == "conversion") {-				parse_cubic_conversion (t);-			}-			 			if (t.get_name () == "postscript_name") { 				font.postscript_name = XmlParser.decode (t.get_content ()); 			}@@ -1119,18 +1114,6 @@ class BirdFontFile : GLib.Object { 		} 	} 	-	private void parse_cubic_conversion (Tag tag) {-		string tolerance = "1";-		-		foreach (Attribute attr in tag.get_attributes ()) {-			if (attr.get_name () == "tolerance") {-				tolerance = attr.get_content ();-			}-		}-		-		font.tolerance = parse_double (tolerance);-	}-	 	private void parse_background_image (Tag tag) { 		string file = ""; 		string data = "";diff --git a/libbirdfont/ExportSettings.vala b/libbirdfont/ExportSettings.valaindex 7e66641..dee61c6 100644--- a/libbirdfont/ExportSettings.vala+++ b/libbirdfont/ExportSettings.vala@@ -24,7 +24,6 @@ public class ExportSettings : TableLayout { 	CheckBox ttf; 	CheckBox eot; 	CheckBox svg;-	TextArea tolerance; 	Button export_action; 	Button name_tab; 	@@ -131,31 +130,6 @@ public class ExportSettings : TableLayout {  		svg.margin_bottom = 20 * MainWindow.units; -		widgets.add (new Text (t_("Conversion Tolerance"), label_size, label_margin));-		-		tolerance = new LineTextArea (label_size);-		tolerance.margin_bottom = 20 * MainWindow.units;-		-		tolerance.set_text (@"$(font.tolerance * 100.0)%");-		tolerance.text_changed.connect ((t) => {-			Font f = BirdFont.get_current_font ();-			string tolerance_percent = t.replace ("%", "");-			tolerance_percent = t.replace (",", ".");-			tolerance_percent = t.replace (" ", "");-			double error_tolerance = double.parse (tolerance_percent);-			-			if (error_tolerance >= 100.0) {-				f.tolerance = 1;-			} else if (error_tolerance <= 0) {-				f.tolerance = 0;-			} else {-				f.tolerance = error_tolerance / 100.0;-			}-		});-		-		widgets.add (tolerance);-		focus_ring.add (tolerance);- 		name_tab = new Button (t_("Name and Description"), margin); 		name_tab.action.connect ((c) => { 			MenuTab.show_description ();diff --git a/libbirdfont/Font.vala b/libbirdfont/Font.valaindex 010fc7a..78e7526 100644--- a/libbirdfont/Font.vala+++ b/libbirdfont/Font.vala@@ -125,7 +125,6 @@ public class Font : GLib.Object { 	public int format_minor = 0; 	 	public int units_per_em = 1024;-	public double tolerance = 1.0;  	public Font () { 		KerningClasses kerning_classes;diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex bbc923f..ec079df 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -212,7 +212,7 @@ public class Glyph : FontDisplay { 		return (!) ttf_data; 	} -	public PathList get_quadratic_paths (double tolerance) {+	public PathList get_quadratic_paths () { 		PointConverter pc; 		PathList pl; 		PathList stroke;@@ -223,11 +223,11 @@ public class Glyph : FontDisplay { 			if (p.stroke > 0) { 				stroke = p.get_completed_stroke (); 				foreach (Path stroke_part in stroke.paths) {-					pc = new PointConverter (stroke_part, tolerance);+					pc = new PointConverter (stroke_part); 					pl.add (pc.get_quadratic_path ()); 				} 			} else {-				pc = new PointConverter (p, tolerance);+				pc = new PointConverter (p); 				pl.add (pc.get_quadratic_path ()); 			} 		}diff --git a/libbirdfont/OpenFontFormat/GlyfData.vala b/libbirdfont/OpenFontFormat/GlyfData.valaindex 924989b..9e58b6f 100644--- a/libbirdfont/OpenFontFormat/GlyfData.vala+++ b/libbirdfont/OpenFontFormat/GlyfData.vala@@ -58,12 +58,11 @@ public class GlyfData : GLib.Object { 		 	public GlyfData (Glyph g) { 		bool process;-		Font font = OpenFontFormatWriter.get_current_font ();-		PathList quadratic_path = g.get_quadratic_paths (font.tolerance); +		PathList qp = g.get_quadratic_paths ();  		 		glyph = g; 						-		foreach (Path p in quadratic_path.paths) {+		foreach (Path p in qp.paths) { 			if (p.points.size > 0) { 				if (!is_empty (p)) { 					// Add points at extrema@@ -77,7 +76,7 @@ public class GlyfData : GLib.Object { 		while (process) { 			points.clear (); 			paths.clear ();-			foreach (Path p in quadratic_path.paths) {+			foreach (Path p in qp.paths) { 				if (!is_empty (p)) { 					paths.add (p); 					foreach (EditPoint ep in p.points) {diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex 0b1b8ea..7e4650e 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -1267,9 +1267,9 @@ public class Path : GLib.Object { 	/** Convert quadratic bezier points to cubic representation of the glyph 	 * for ttf-export. 	 */ -	public Path get_quadratic_points (double tolerance) {+	public Path get_quadratic_points () { 		PointConverter converter;-		converter = new PointConverter (this, tolerance);+		converter = new PointConverter (this);		 		return converter.get_quadratic_path (); 	} diff --git a/libbirdfont/PointConverter.vala b/libbirdfont/PointConverter.valaindex 88951d9..5880a3f 100644--- a/libbirdfont/PointConverter.vala+++ b/libbirdfont/PointConverter.vala@@ -22,11 +22,9 @@ public class PointConverter {  	Path original_path; 	Path quadratic_path;-	double error_tolerance = 1; -	public PointConverter (Path path, double tolerance) {	+	public PointConverter (Path path) {	 		original_path = path;-		error_tolerance = tolerance; 	}  	public Path get_quadratic_path () {@@ -111,7 +109,7 @@ public class PointConverter { 						out distance, out e, out step); 			} 			-			if (distance > 0.1 + 0.1 * error_tolerance) { //  range 0.1 - 0.4,+			if (distance > 0.2) { //  range 0.1 - 0.4, 				quadratic_path.insert_new_point_on_path (e); 				points_in_segment++; 				size += 2; // the new point + segment startdiff --git a/libbirdfont/TestCases.vala b/libbirdfont/TestCases.valaindex fa79d61..b6ae008 100644--- a/libbirdfont/TestCases.vala+++ b/libbirdfont/TestCases.vala@@ -645,7 +645,7 @@ class TestCases { 		g = MainWindow.get_current_glyph (); 		 		foreach (Path path in g.get_all_paths ()) {-			paths.append (path.get_quadratic_points (1.0));+			paths.append (path.get_quadratic_points ()); 			paths.append (path.copy ()); 		} 				@@ -663,7 +663,7 @@ class TestCases { 		p.add (-10, -10); 		p.close (); 		g.add_path (p);-		g.add_path (p1.get_quadratic_points (1.0));+		g.add_path (p1.get_quadratic_points ());  		e0 = new EditPoint (20, 40); 		e1 = new EditPoint (40, 40);@@ -687,7 +687,7 @@ class TestCases { 		e3.process_tied_handle ();  		g.add_path (p1);-		g.add_path (p1.get_quadratic_points (1.0));+		g.add_path (p1.get_quadratic_points ()); 		 		foreach (Path path in paths) { 			g.add_path (path);

Contact

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