Clone in a terminal:
Commit 98c6d51
Johan Mattsson - 2012-08-17T08:53:30+00:00
98c6d517571cc3d67afbb13b3be8c21533df483ejohan.mattsson.m@gmail.com

tab width from font metrix

Changed files (4)

Diff

diff --git a/src/BackgroundSelection.vala b/src/BackgroundSelection.valaindex 737717e..2463483 100644--- a/src/BackgroundSelection.vala+++ b/src/BackgroundSelection.vala@@ -104,13 +104,11 @@ class BackgroundSelection : FontDisplay { 	} 		 	private bool draw_thumbnail (string file, double x, double y, Context cr, int box_index) {-		GlyphBackgroundImage bg = new GlyphBackgroundImage (file);-		File thumbnail = bg.get_thumbnail_file (); 		Pixbuf pixbuf = new Pixbuf.from_file (file); 		ImageSurface img = new ImageSurface.for_data (pixbuf.get_pixels (), Format.ARGB32, pixbuf.get_width (), pixbuf.get_height (), pixbuf.get_rowstride ()); 		 		if (img.status () != Cairo.Status.SUCCESS) {-			warning (@"Failed to load $file (height: $(pixbuf.get_height ()), width: $(pixbuf.get_width ()), stride: $(pixbuf.get_rowstride ()))");+			warning (@"Failed to load $file as gdk pixbuf. (height: $(pixbuf.get_height ()), width: $(pixbuf.get_width ()), stride: $(pixbuf.get_rowstride ()))"); 			return false; 		} diff --git a/src/CutBackgroundTool.vala b/src/CutBackgroundTool.valaindex ce5249d..f614efc 100644--- a/src/CutBackgroundTool.vala+++ b/src/CutBackgroundTool.vala@@ -112,7 +112,6 @@ class CutBackgroundTool : Tool { 		return fabs (y1 - y2); 	} -	// Todo: nice gimp style crop 	void do_cut () { 		double x, y; 		int h, w;diff --git a/src/OpenFontFormatWriter.vala b/src/OpenFontFormatWriter.valaindex ee47234..a114d89 100644--- a/src/OpenFontFormatWriter.vala+++ b/src/OpenFontFormatWriter.vala@@ -1446,11 +1446,11 @@ class GlyfTable : Table { 		fd.add_16 (tymax);
 		fd.seek_end ();
 
-		print (@"\n");
-		print (@"txmin: $txmin\n");
-		print (@"tymin: $tymin\n");
-		print (@"txmax: $txmax\n");
-		print (@"tymax: $tymax\n");
+		printd (@"\n");
+		printd (@"txmin: $txmin\n");
+		printd (@"tymin: $tymin\n");
+		printd (@"txmax: $txmax\n");
+		printd (@"tymax: $tymax\n");
 
 		// save this for head table
 		if (this.xmin > txmin) this.xmin = txmin;
@@ -1514,7 +1514,7 @@ class GlyfTable : Table { 			location_offsets.append (fd.length ());
 			process_glyph (g, fd);
 			
-			print (@"loca fd.length (): $(fd.length ())\n");
+			printd (@"loca fd.length (): $(fd.length ())\n");
 		}
 
 		location_offsets.append (fd.length ()); // last entry in loca table is special
@@ -1927,15 +1927,19 @@ class CmapTable : Table { 			platform = dis.read_ushort ();
 			encoding = dis.read_ushort ();
 			sub_offset = dis.read_ulong ();	
-			
+		
 			if (platform == 3 && encoding == 1) {
 				printd (@"Parsing Unicode BMP (UCS-2) Platform: $platform Encoding: $encoding\n");
 				subtable = new CmapSubtableWindowsUnicode ();
 				subtable.offset = offset + sub_offset;
 				subtables.append (subtable);
 			} else {
-				stderr.printf (@"Unknown encoding. Platform: $platform Encoding: $encoding.\n");
-			}	
+				stderr.printf (@"Unknown cmap format. Platform: $platform Encoding: $encoding.\n");
+			}
+			
+			if (encoding == 3) {
+				warning ("Font contains a cmap table with the obsolete encoding 3.");
+			}
 		}
 		
 		if (subtables.length () == 0) {
@@ -4932,7 +4936,7 @@ public static uint16 largest_pow2 (uint16 max) { }
 
 void printd (string s) {
-	// print (s);
+	print (s);
 }
 
 }
diff --git a/src/TabBar.vala b/src/TabBar.valaindex fb978f8..5cae584 100644--- a/src/TabBar.vala+++ b/src/TabBar.vala@@ -297,18 +297,26 @@ class TabBar : DrawingArea { 		} 	} 	-	public void add_tab (FontDisplay display_item, double tab_width = 30, bool always_open = false) {+	public void add_tab (FontDisplay display_item, double tab_width = -1, bool always_open = false) {+		ImageSurface im = new ImageSurface (Format.RGB24, 0, 0);+		Context cr = new Context (im);+		TextExtents	te;+		 		int s = (tabs.length () == 0) ? 0 : selected + 1; 		+		if (tab_width < 0) {+			cr.text_extents (display_item.get_name (), out te);+			tab_width = te.width + 30;+		}+				 		tabs.insert (new Tab (display_item, tab_width, always_open), s); 		select_tab (s); 	} 	 	/** Returns true if the new item was added to the bar. */-	public bool add_unique_tab (FontDisplay display_item, double tab_width = 30, bool always_open = false) {-		+	public bool add_unique_tab (FontDisplay display_item, double tab_width = -1, bool always_open = false) { 		bool i = select_tab_name (display_item.get_name ());-		+ 		if (!i) { 			add_tab (display_item, tab_width, always_open); 			return true;

Contact

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