Clone in a terminal:
Commit 571a069
Johan Mattsson - 2013-09-01T21:25:49+00:00
571a069b3d640c1fbfdf40b5fd4d76ac1cc26652johan.mattsson.m@gmail.com

Support for bold and italic variations in the OS/2 table

Changed files (6)

Diff

diff --git a/birdfont/GtkWindow.vala b/birdfont/GtkWindow.valaindex ac5b96c..495cc20 100644--- a/birdfont/GtkWindow.vala+++ b/birdfont/GtkWindow.vala@@ -129,9 +129,9 @@ public class GtkWindow : Gtk.Window, NativeWindow { 							 							File preview_directory = BirdFont.get_preview_directory (); 							-							File f_ttf = font.get_folder ().get_child (@"$(font.get_name ()).ttf");-							File f_eot = font.get_folder ().get_child (@"$(font.get_name ()).eot");-							File f_svg = font.get_folder ().get_child (@"$(font.get_name ()).svg");+							File f_ttf = font.get_folder ().get_child (@"$(font.get_full_name ()).ttf");+							File f_eot = font.get_folder ().get_child (@"$(font.get_full_name ()).eot");+							File f_svg = font.get_folder ().get_child (@"$(font.get_full_name ()).svg");  							if (f_ttf.query_exists ()) { 								f_ttf.delete ();@@ -148,8 +148,8 @@ public class GtkWindow : Gtk.Window, NativeWindow { 							ExportTool.export_ttf_font ();							 							ExportTool.export_svg_font (); 							-							File r_ttf = preview_directory.get_child (@"$(font.get_name ())$rid.ttf");-							File r_svg = preview_directory.get_child (@"$(font.get_name ())$rid.svg");+							File r_ttf = preview_directory.get_child (@"$(font.get_full_name ())$rid.ttf");+							File r_svg = preview_directory.get_child (@"$(font.get_full_name ())$rid.svg"); 							 							if (BirdFont.win32) { 								f_ttf.copy (r_ttf, FileCopyFlags.NONE);@@ -158,9 +158,9 @@ public class GtkWindow : Gtk.Window, NativeWindow { 							f_svg.copy (r_svg, FileCopyFlags.NONE);  							while ((line = dis.read_line (null)) != null) {-								line = ((!) line).replace (@"$(font.get_name ()).ttf", @"$(FontDisplay.path_to_uri ((!) f_ttf.get_path ()))?$rid");-								line = ((!) line).replace (@"$(font.get_name ()).eot", @"$(FontDisplay.path_to_uri ((!) f_eot.get_path ()))?$rid");-								line = ((!) line).replace (@"$(font.get_name ()).svg", @"$(FontDisplay.path_to_uri ((!) f_svg.get_path ()))?$rid");+								line = ((!) line).replace (@"$(font.get_full_name ()).ttf", @"$(FontDisplay.path_to_uri ((!) f_ttf.get_path ()))?$rid");+								line = ((!) line).replace (@"$(font.get_full_name ()).eot", @"$(FontDisplay.path_to_uri ((!) f_eot.get_path ()))?$rid");+								line = ((!) line).replace (@"$(font.get_full_name ()).svg", @"$(FontDisplay.path_to_uri ((!) f_svg.get_path ()))?$rid"); 								sb.append ((!) line); 							} 					diff --git a/libbirdfont/ExportTool.vala b/libbirdfont/ExportTool.valaindex ba4ce45..f3ab9fc 100644--- a/libbirdfont/ExportTool.vala+++ b/libbirdfont/ExportTool.vala@@ -153,7 +153,6 @@ public class ExportTool : GLib.Object { 			critical (@"$(e.message)"); 		} 	}-	  	public static void export_all () { 		bool f;@@ -177,7 +176,7 @@ public class ExportTool : GLib.Object { 	public static void generate_html_document (string html_file, Font font) { 		File file = File.new_for_path (html_file); 		DataOutputStream os;-		string name = font.get_name ();+		string name = font.get_full_name ();  		try { 			os = new DataOutputStream (file.create(FileCreateFlags.REPLACE_DESTINATION));@@ -465,8 +464,8 @@ os.put_string ( 			// create a copy of current font and use it in a separate  			// export thread 			temp_file = current_font.save_backup ();-			ttf_file = folder.get_child (current_font.get_name () + ".ttf");-			eot_file = folder.get_child (current_font.get_name () + ".eot");+			ttf_file = folder.get_child (current_font.get_full_name () + ".ttf");+			eot_file = folder.get_child (current_font.get_full_name () + ".eot");  			if (ttf_file.query_exists ()) { 				ttf_file.delete ();@@ -522,7 +521,7 @@ os.put_string ( 		 	public static bool export_svg_font_path (File folder) { 		Font font = BirdFont.get_current_font ();-		string file_name = @"$(font.get_name ()).svg";+		string file_name = @"$(font.get_full_name ()).svg"; 		File file; 		SvgFontFormatWriter fo; 		diff --git a/libbirdfont/Font.vala b/libbirdfont/Font.valaindex f838640..8fac885 100644--- a/libbirdfont/Font.vala+++ b/libbirdfont/Font.vala@@ -171,6 +171,10 @@ public class Font : GLib.Object { 		this.name = n; 	} 	+	public string get_full_name () {+		return full_name;+	}+	 	public string get_name () { 		return name; 	}diff --git a/libbirdfont/OpenFontFormat/NameTable.vala b/libbirdfont/OpenFontFormat/NameTable.valaindex f075811..109e101 100644--- a/libbirdfont/OpenFontFormat/NameTable.vala+++ b/libbirdfont/OpenFontFormat/NameTable.vala@@ -212,8 +212,6 @@ class NameTable : Table { 		// platform 1 		foreach (string s in text) { 			fd.add_str (s);-			print (s);-			print ("\n"); 		} 		 		// platform 3diff --git a/libbirdfont/OpenFontFormat/Os2Table.vala b/libbirdfont/OpenFontFormat/Os2Table.valaindex 92c630a..3a5c521 100644--- a/libbirdfont/OpenFontFormat/Os2Table.vala+++ b/libbirdfont/OpenFontFormat/Os2Table.vala@@ -26,29 +26,35 @@ class Os2Table : Table { 	 	public void process (GlyfTable glyf_table) { 		FontData fd = new FontData ();-+		Font font = OpenFontFormatWriter.get_current_font (); 		int16 ascender; 		int16 descender; 		-		fd.add_u16 (0x0002); // USHORT Version 0x0000, 0x0001, 0x0002, 0x0003, 0x0004--		fd.add_16 (glyf_table.get_average_width ()); // SHORT xAvgCharWidth--		fd.add_u16 (400); // USHORT usWeightClass (400 is normal)-		fd.add_u16 (5); // USHORT usWidthClass (5 is normal)-		fd.add_u16 (0); // USHORT fsType--		fd.add_16 (40); // SHORT ySubscriptXSize-		fd.add_16 (40); // SHORT ySubscriptYSize-		fd.add_16 (40); // SHORT ySubscriptXOffset-		fd.add_16 (40); // SHORT ySubscriptYOffset-		fd.add_16 (40); // SHORT ySuperscriptXSize-		fd.add_16 (40); // SHORT ySuperscriptYSize-		fd.add_16 (40); // SHORT ySuperscriptXOffset-		fd.add_16 (40); // SHORT ySuperscriptYOffset-		fd.add_16 (40); // SHORT yStrikeoutSize-		fd.add_16 (200); // SHORT yStrikeoutPosition-		fd.add_16 (40); // SHORT sFamilyClass+		fd.add_u16 (0x0002); // version++		fd.add_16 (glyf_table.get_average_width ()); // xAvgCharWidth++		// usWeightClass (400 is normal, 700 is bold)+		if (font.subfamily.index_of ("Bold") == -1) {+			fd.add_u16 (400); +		} else {+			fd.add_u16 (700);+		} +		+		fd.add_u16 (5); // usWidthClass (5 is normal)+		fd.add_u16 (0); // fsType++		fd.add_16 (40); // ySubscriptXSize+		fd.add_16 (40); // ySubscriptYSize+		fd.add_16 (40); // ySubscriptXOffset+		fd.add_16 (40); // ySubscriptYOffset+		fd.add_16 (40); // ySuperscriptXSize+		fd.add_16 (40); // ySuperscriptYSize+		fd.add_16 (40); // ySuperscriptXOffset+		fd.add_16 (40); // ySuperscriptYOffset+		fd.add_16 (40); // yStrikeoutSize+		fd.add_16 (200); // yStrikeoutPosition+		fd.add_16 (40); // sFamilyClass  		// FIXME: PANOSE 		fd.add (0); @@ -64,39 +70,44 @@ class Os2Table : Table {  		// FIXME: 		fd.add_u32 (0); // ulUnicodeRange1 Bits 0-31-		fd.add_u32 (0); // ULONG ulUnicodeRange2 Bits 32-63-		fd.add_u32 (0); // ULONG ulUnicodeRange3 Bits 64-95-		fd.add_u32 (0); // ULONG ulUnicodeRange4 Bits 96-127+		fd.add_u32 (0); // ulUnicodeRange2 Bits 32-63+		fd.add_u32 (0); // ulUnicodeRange3 Bits 64-95+		fd.add_u32 (0); // ulUnicodeRange4 Bits 96-127  		fd.add_tag ("----"); // VendID--		fd.add_u16 (0); // USHORT fsSelection 		-		fd.add_u16 (glyf_table.get_first_char ()); // USHORT usFirstCharIndex-		fd.add_u16 (glyf_table.get_last_char ()); // USHORT usLastCharIndex+		 // fsSelection (1 for italic 0 for upright)+		if (font.subfamily.index_of ("Italic") == -1) {+			fd.add_u16 (0);+		} else {+			fd.add_u16 (1);+		}+		+		fd.add_u16 (glyf_table.get_first_char ()); // usFirstCharIndex+		fd.add_u16 (glyf_table.get_last_char ()); // usLastCharIndex  		ascender = glyf_table.ymax; 		descender = -glyf_table.ymin; 		-		fd.add_16 (ascender); // SHORT sTypoAscender-		fd.add_16 (descender); // SHORT sTypoDescender-		fd.add_16 (3); // SHORT sTypoLineGap+		fd.add_16 (ascender); // sTypoAscender+		fd.add_16 (descender); // sTypoDescender+		fd.add_16 (3); // sTypoLineGap -		fd.add_u16 (ascender); // USHORT usWinAscent-		fd.add_u16 (descender); // USHORT usWinDescent+		fd.add_u16 (ascender); // usWinAscent+		fd.add_u16 (descender); // usWinDescent  		// FIXA:-		fd.add_u32 (0); // ULONG ulCodePageRange1 Bits 0-31-		fd.add_u32 (0); // ULONG ulCodePageRange2 Bits 32-63+		fd.add_u32 (0); // ulCodePageRange1 Bits 0-31+		fd.add_u32 (0); // ulCodePageRange2 Bits 32-63 -		fd.add_16 (ascender); // SHORT sxHeight version 0x0002 and later-		fd.add_16 (ascender); // SHORT sCapHeight version 0x0002 and later+		fd.add_16 (ascender); // sHeight+		fd.add_16 (ascender); // sCapHeight -		fd.add_16 (0); // USHORT usDefaultChar version 0x0002 and later-		fd.add_16 (0x0020); // USHORT usBreakChar version 0x0002 and later, also known as space+		fd.add_16 (0); // usDefaultChar+		fd.add_16 (0x0020); // usBreakChar also known as space 		-		// FIXA: calculate these values-		fd.add_16 (1); // USHORT usMaxContext version 0x0002 and later+		// FIXME: calculate these values+		fd.add_16 (1); // usMaxContext  		// padding 		fd.pad ();diff --git a/libbirdfont/Preview.vala b/libbirdfont/Preview.valaindex 0f8a53b..7238f2b 100644--- a/libbirdfont/Preview.vala+++ b/libbirdfont/Preview.vala@@ -32,7 +32,7 @@ public class Preview : FontDisplay {  	public static File get_file () { 		Font font = BirdFont.get_current_font ();-		string path = @"$(font.get_name ()).html";+		string path = @"$(font.get_full_name ()).html"; 		File dir = font.get_folder (); 		File file = dir.get_child (path); 		

Contact

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