Clone in a terminal:
Commit a2a84e9
Johan Mattsson - 2014-10-23T06:09:48+00:00
a2a84e9365c99c746de96d2fb00cf1881ece8600johan.mattsson.m@gmail.com

Update grid when switching tab

Changed files (12)

Diff

diff --git a/configure b/configureindex aa63647..1d7ee79 100755--- a/configure+++ b/configure@@ -49,7 +49,7 @@ def test_library_version (lib): def has_posixvala (): 	posixvala = test_library_version ('posixvala') 	if not posixvala:-		print (OKGREEN + "Posix profile disable Glib will be used." + ENDC)+		print (OKGREEN + "Glib will be used instead of Posix (libc)." + ENDC) 		return "False" 		 	return "True"diff --git a/dodo.py b/dodo.pyindex 2b60c64..5278891 100644--- a/dodo.py+++ b/dodo.py@@ -58,7 +58,7 @@ if not config.POSIXVALA:     ] else:     LIBBIRD_XML_LIBS = [-        'posixvala'	+        'posix'	     ]  def task_build ():@@ -94,7 +94,12 @@ valac_options = [  libbirdxml = Vala(src='libbirdxml', build='build', library='birdxml', so_version=version.LIBBIRDXML_SO_VERSION, pkg_libs=LIBBIRD_XML_LIBS) def task_libbirdxml():-    yield libbirdxml.gen_c(valac_options)++    if config.POSIXVALA:+        yield libbirdxml.gen_c(valac_options + ['--nostdpkg'])+    else:+        yield libbirdxml.gen_c(valac_options)+     yield libbirdxml.gen_o(['-fPIC'])     yield libbirdxml.gen_so()     yield libbirdxml.gen_ln()diff --git a/libbirdfont/Font.vala b/libbirdfont/Font.valaindex 638b831..2c68ec5 100644--- a/libbirdfont/Font.vala+++ b/libbirdfont/Font.vala@@ -392,6 +392,9 @@ public class Font : GLib.Object { 		g.add_path (i); 		g.add_path (p); +		i.recalculate_linear_handles ();+		p.recalculate_linear_handles ();+ 		return gc; 	} diff --git a/libbirdfont/Glyph.vala b/libbirdfont/Glyph.valaindex 289b1e7..4c13689 100644--- a/libbirdfont/Glyph.vala+++ b/libbirdfont/Glyph.vala@@ -340,6 +340,8 @@ public class Glyph : FontDisplay { 		KeyBindings.set_require_modifier (false); 		glyph_sequence = Preferences.get ("glyph_sequence"); 		+		GridTool.update_lines ();+		 		if (!is_null (MainWindow.native_window)) { 			MainWindow.native_window.set_scrollbar_size (0); 		}@@ -1353,7 +1355,7 @@ public class Glyph : FontDisplay { 				stroke = StrokeTool.get_stroke (p, p.stroke); 				draw_path_list (stroke, cr, Color.black ()); 			} else {-				p.draw_path (cr, Color.black ());+				p.draw_path (cr, this, Color.black ()); 			} 		} 		cr.fill ();@@ -1369,7 +1371,7 @@ public class Glyph : FontDisplay { 					draw_path_list (StrokeTool.get_stroke (p, p.stroke), cr, get_path_fill_color ()); 				} -				p.draw_path (cr, get_path_fill_color ());+				p.draw_path (cr, this, get_path_fill_color ()); 			} 			cr.fill (); 			cr.restore ();@@ -1397,7 +1399,7 @@ public class Glyph : FontDisplay { 			cr.new_path (); 			foreach (Path p in path_list) { 				if (p.stroke == 0) {-					p.draw_path (cr, Color.black ());+					p.draw_path (cr, this, Color.black ()); 				} else { 					draw_path_list (StrokeTool.get_stroke (p, p.stroke), cr, Color.black ()); 				}@@ -1410,7 +1412,7 @@ public class Glyph : FontDisplay { 				cr.save (); 				cr.new_path (); 				if (p.stroke == 0) {-					p.draw_path (cr);+					p.draw_path (cr, this); 				} else { 					draw_path_list (StrokeTool.get_stroke (p, p.stroke), cr); 				}@@ -1433,7 +1435,7 @@ public class Glyph : FontDisplay { 	 	private void draw_path_list (PathList pl, Context cr, Color? c = null) { 		foreach (Path p in pl.paths) {-			p.draw_path (cr, c);+			p.draw_path (cr, this, c); 		} 	} 		diff --git a/libbirdfont/Path.vala b/libbirdfont/Path.valaindex 7c6f1c6..1e715b4 100644--- a/libbirdfont/Path.vala+++ b/libbirdfont/Path.vala@@ -287,12 +287,11 @@ public class Path { 	 * Call Context.new_path (); before this method and Context.fill () 	 * to show the path. 	 */-	public void draw_path (Context cr, Color? color = null) {+	public void draw_path (Context cr, Glyph glyph, Color? color = null) { 		unowned EditPoint? n = null; 		unowned EditPoint en; 		unowned EditPoint em; 		Color c;-		Glyph g; 		double center_x, center_y; 		double ex, ey; 		@@ -300,10 +299,8 @@ public class Path { 			return; 		} -		g = MainWindow.get_current_glyph ();-		-		center_x = g.allocation.width / 2.0;-		center_y = g.allocation.height / 2.0;+		center_x = glyph.allocation.width / 2.0;+		center_y = glyph.allocation.height / 2.0;  		ex = center_x + points.get (0).x; 		ey = center_y - points.get (0).y;diff --git a/libbirdfont/Renderer/TextArea.vala b/libbirdfont/Renderer/TextArea.valaindex 90a24f2..7c34c45 100644--- a/libbirdfont/Renderer/TextArea.vala+++ b/libbirdfont/Renderer/TextArea.vala@@ -23,6 +23,7 @@ public class TextArea { 	Font font; 	string text; 	GlyphSequence glyph_sequence;+	double line_gap = 20; 	 	public TextArea () { 		font = new Font ();@@ -62,12 +63,7 @@ public class TextArea { 		return f != null; 	} 	-	public void draw (Context cr, int x, int y, int width, int height) {-		WidgetAllocation wa = new WidgetAllocation.for_area (x, y, width, height);-		draw_glyphs (wa, cr);-	}--	public void draw_glyphs (WidgetAllocation allocation, Context cr) {+	public void draw (Context cr, int px, int py, int width, int height, double font_size_in_pixels) { 		Glyph glyph; 		double x, y, w, kern; 		int i, wi;@@ -76,18 +72,21 @@ public class TextArea { 		GlyphRange? gr_left, gr_right; 		double row_height; 		GlyphSequence word;+		double center_x, center_y;+		double ratio; 		 		i = 0;+		row_height = get_row_height (); 		-		cr.save ();-		cr.scale (KerningTools.font_size, KerningTools.font_size);+		ratio = font_size_in_pixels / row_height; 		-		glyph = MainWindow.get_current_glyph ();+		cr.save ();+		cr.scale (ratio, ratio); 		-		row_height = get_row_height ();-	-		y = get_row_height () + font.base_line + 20;-		x = 20;+		glyph = new Glyph ("", '\0');++		y = get_row_height () + font.base_line + py;+		x = px; 		w = 0; 		prev = null; 		kern = 0;@@ -98,10 +97,6 @@ public class TextArea { 		gr_left = null; 		gr_right = null; 		foreach (Glyph? g in word_with_ligatures.glyph) {-			if (g == null) {-				continue;-			}-			 			if (prev == null || wi == 0) { 				kern = 0; 			} else {@@ -115,19 +110,18 @@ public class TextArea { 			} 					 			// draw glyph-			if (g == null) {-				w = 50;-			} else {-				glyph = (!) g;+			glyph = (g == null) ? font.get_not_def_character ().get_current () : (!) g; -				cr.save ();-				glyph.add_help_lines ();-				cr.translate (kern + x - glyph.get_lsb () - Glyph.xc (), glyph.get_baseline () + y  - Glyph.yc ());-				glyph.draw_paths (cr);-				cr.restore ();-				-				w = glyph.get_width ();-			}+			center_x = glyph.allocation.width / 2.0;+			center_y = glyph.allocation.height / 2.0;++			cr.save ();+			glyph.add_help_lines ();+			cr.translate (kern + x - center_x - glyph.get_lsb (), y - center_y + glyph.get_baseline ());+			glyph.draw_paths (cr);+			cr.restore ();+			+			w = glyph.get_width ();  			x += w + kern; @@ -137,7 +131,7 @@ public class TextArea { 			i++; 		} 					-		y += row_height + 20;+		y += row_height + line_gap; 		x = 20; 			 		cr.restore ();		diff --git a/libbirdfont/Renderer/TextTab.vala b/libbirdfont/Renderer/TextTab.valaindex d931435..ce3faab 100644--- a/libbirdfont/Renderer/TextTab.vala+++ b/libbirdfont/Renderer/TextTab.vala@@ -29,12 +29,12 @@ public class TextTab : FontDisplay {  		text_area2 = new TextArea (); 		text_area2.load_font ("testfont.bf");-		text_area2.set_text ("Birdfont");+		text_area2.set_text ("Birdfont ÅÄÖ"); 	}  	public override void draw (WidgetAllocation allocation, Context cr) {-		text_area.draw (cr, 100, 100, 200, 200);-		text_area2.draw (cr, 100, 200, 200, 200);+		text_area.draw (cr, 0, 0, 200, 200, 16);+		text_area2.draw (cr, 0, 100, 200, 200, 16); 	}	 } diff --git a/libbirdxml/Attribute.vala b/libbirdxml/Attribute.valaindex e0fac1c..8b935d5 100644--- a/libbirdxml/Attribute.vala+++ b/libbirdxml/Attribute.vala@@ -49,12 +49,12 @@ public class Attribute { 	/** Decrement the reference count and free the object when zero object are holding references to it.*/ 	public void unref () { 		if (--refcount == 0) {-			this.free ();+			this.finalize (); 		} 	} 	 	/** -	 * @return name space part for this attribute.+	 * @return namespace part for this attribute. 	 */ 	public string get_namespace () { 		return ns;@@ -74,7 +74,7 @@ public class Attribute { 		return content; 	} 	-	private extern void free ();+	private extern void finalize (); }  }diff --git a/libbirdxml/Attributes.vala b/libbirdxml/Attributes.valaindex f711ecf..b82c127 100644--- a/libbirdxml/Attributes.vala+++ b/libbirdxml/Attributes.vala@@ -42,7 +42,7 @@ public class Attributes { 	/** Decrement the reference count and free the object when zero object are holding references to it.*/ 	public void unref () { 		if (--refcount == 0) {-			this.free ();+			this.finalize (); 		} 	} 	@@ -89,14 +89,14 @@ public class Attributes { 		/** Decrement the reference count and free the object when zero object are holding references to it.*/ 		public void unref () { 			if (--iterator_refcount == 0) {-				this.free ();+				this.finalize (); 			} 		} 		-		private extern void free ();+		private extern void finalize (); 	} 	-	private extern void free ();+	private extern void finalize (); }  }diff --git a/libbirdxml/Tag.vala b/libbirdxml/Tag.valaindex 2822e86..67673a4 100644--- a/libbirdxml/Tag.vala+++ b/libbirdxml/Tag.vala@@ -65,7 +65,7 @@ public class Tag { 	/** Decrement the reference count and free the object when zero object are holding references to it.*/ 	public void unref () { 		if (--refcount == 0) {-			this.free ();+			this.finalize (); 		} 	} 	@@ -435,11 +435,11 @@ public class Tag { 		/** Decrement the reference count and free the object when zero object are holding references to it.*/ 		public void unref () { 			if (--iterator_efcount == 0) {-				this.free ();+				this.finalize (); 			} 		} 		-		private extern void free ();+		private extern void finalize (); 	} 	 	internal void warn (string message) {@@ -448,7 +448,7 @@ public class Tag { 		} 	} 	-	private extern void free ();+	private extern void finalize (); }  }diff --git a/libbirdxml/Xml.vala b/libbirdxml/Xml.valaindex ca62416..5694782 100644--- a/libbirdxml/Xml.vala+++ b/libbirdxml/Xml.vala@@ -96,7 +96,7 @@ public class XmlParser { 	/** Decrement the reference count and free the object when zero object are holding references to it.*/ 	public void unref () { 		if (--refcount == 0) {-			this.free ();+			this.finalize (); 		} 	} 		@@ -201,7 +201,7 @@ public class XmlParser { 		print ("\n"); 	} 	-	private extern void free ();+	private extern void finalize (); }  }diff --git a/scripts/bavala.py b/scripts/bavala.pyindex 05b3592..fc48382 100644--- a/scripts/bavala.py+++ b/scripts/bavala.py@@ -91,7 +91,7 @@ class Vala(object):      def gen_c(self, opts):         """translate code from vala to C and create .vapi"""-        options = ['--ccode', '--save-temps']+        options = ['--ccode']         options.extend(opts)         params = {             'basedir': join(self.build, self.src),@@ -132,13 +132,14 @@ class Vala(object):         def compile_cmd(conf, opts, libs, pos):             flags = []             for l in libs:-                process = subprocess.Popen ('pkg-config --cflags ' + l, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)-                cflags = process.stdout.readline()-                process.communicate()[0]-                if not process.returncode == 0:-                    print ( "Library not found: " + l)-                    exit (1)-                flags += [cflags.strip ()]+		if not l == "posix":+                    process = subprocess.Popen ('pkg-config --cflags ' + l, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)+                    cflags = process.stdout.readline()+                    process.communicate()[0]+                    if not process.returncode == 0:+                        print ( "Library not found: " + l)+                        exit (1)+                    flags += [cflags.strip ()]              return cmd(config.CC, opts, flags, pos) @@ -166,13 +167,14 @@ class Vala(object):              flags = []             for l in libs:-                process = subprocess.Popen ('pkg-config --cflags ' + l, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)-                cflags = process.stdout.readline()-                process.communicate()[0]-                if not process.returncode == 0:-                    print ( "Library not found: " + l)-                    exit (1)-                flags += [cflags.strip ()]+                if not l == "posix":+                    process = subprocess.Popen ('pkg-config --cflags ' + l, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)+                    cflags = process.stdout.readline()+                    process.communicate()[0]+                    if not process.returncode == 0:+                        print ( "Library not found: " + l)+                        exit (1)+                    flags += [cflags.strip ()]              if generated_libs: 			    flags += [generated_libs]

Contact

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