Clone in a terminal:
Commit 3c1d0bf
Johan Mattsson - 2012-09-19T21:31:00+00:00
3c1d0bfed0fa52cb1cacd5bf8dfb94740cbdbd44johan.mattsson.m@gmail.com

use double and not int for glyph width

Changed files (2)

Diff

diff --git a/src/Glyph.vala b/src/Glyph.valaindex 9ebea4e..a986224 100644--- a/src/Glyph.vala+++ b/src/Glyph.vala@@ -436,7 +436,7 @@ class Glyph : FontDisplay { 	} 	 	public double get_width () {-		return (int) Math.fabs (right_limit / SCALE - left_limit / SCALE);+		return Math.fabs (right_limit / SCALE - left_limit / SCALE); 	}  	public unichar get_unichar () {@@ -728,7 +728,7 @@ class Glyph : FontDisplay { 	public static int reverse_path_coordinate_x (double x) { 		Glyph g = MainWindow.get_current_glyph (); 		return_if_fail (g.view_zoom != 0);-		return (int) ((x - g.view_offset_x + g.xc ()) * g.view_zoom + 0.5);+		return (int) ((x - g.view_offset_x + g.xc ()) * g.view_zoom); 	}  	public static double path_coordinate_y (double y) {@@ -739,7 +739,7 @@ class Glyph : FontDisplay { 	public static int reverse_path_coordinate_y (double y) { 		Glyph g = MainWindow.get_current_glyph (); 		y = ((y + g.view_offset_y - g.yc ()) * g.view_zoom);-		return (int) (-y + 0.5);+		return (int) (-y); 	}  	public static void reverse (double x, double y, out int rx, out int ry) {@@ -1774,6 +1774,8 @@ class Glyph : FontDisplay { 			}  			if (!juxtaposed.is_empty ()) {+				print (@"Glyph.xc () $(Glyph.xc ()) + left $left + x $x + kern $kern\n");+						 				cr.save (); 				cr.scale (glyph.view_zoom, glyph.view_zoom); 				cr.translate (-glyph.view_offset_x, -glyph.view_offset_y);diff --git a/src/Line.vala b/src/Line.valaindex 7e883b4..5423fc8 100644--- a/src/Line.vala+++ b/src/Line.vala@@ -122,10 +122,10 @@ class Line : GLib.Object { 		Glyph g = MainWindow.get_current_glyph (); 		 		if (vertical) {-			p = (pos - g.view_offset_x + (g.allocation.width / 2.0)) * g.view_zoom;+			p = g.reverse_path_coordinate_x (pos); 			queue_draw_area ((int)p - 10, 0, 200, g.allocation.height); 		} else {-			p = (pos - g.view_offset_y + (g.allocation.height / 2.0)) * g.view_zoom;+			p = g.reverse_path_coordinate_y (pos); 			queue_draw_area (0, (int)p - 10, g.allocation.width, 300); 		} 	}	@@ -150,10 +150,10 @@ class Line : GLib.Object { 			redraw_line (); // clear old position 			 			if (is_vertical ()) {-				pos = x * ivz + g.view_offset_x - (g.allocation.width / 2.0);+				pos = Glyph.path_coordinate_x (x); 				redraw_line (); // draw at new position 			} else {-				pos = y * ivz + g.view_offset_y - (g.allocation.height / 2.0);+				pos = Glyph.path_coordinate_y (y); 				redraw_line (); 			} 

Contact

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