Commit cab83b2
Add italic angle to font meta data
Changed files (7)
modifiedfixed-kerning-example/README.txtmodifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/DescriptionDisplay.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/OpenFontFormat/FontData.valamodifiedlibbirdfont/OpenFontFormat/PostTable.valamodifiedscripts/version.py
Diff
@@ -1,4 +1,4 @@-The FK Table+The FK Table (version 1.0) This is a reference implementation of a new kerning table that stores fixed point 16.16 values. The idea is to get better precision for kerning of OTF @@ -8,8 +8,6 @@ The code is small and hopefully easy to understand. The parser needs around 200 lines of code and around 40 more lines are needed to add support for writing the table. -Please ask if you need help or clarifications.- All code related to the FK feature in this folder is example code. Copy and paste of this code into any project with any license is permitted. @@ -24,7 +24,7 @@ class BirdFontFile : GLib.Object { Font font; public const int FORMAT_MAJOR = 2;- public const int FORMAT_MINOR = 3;+ public const int FORMAT_MINOR = 4; public const int MIN_FORMAT_MAJOR = 0; public const int MIN_FORMAT_MINOR = 0;@@ -390,6 +390,7 @@ class BirdFontFile : GLib.Object { os.put_string (@"<license>$(Markup.escape_text (font.license))</license>\n"); os.put_string (@"<license_url>$(Markup.escape_text (font.license_url))</license_url>\n"); os.put_string (@"<weight>$(font.weight)</weight>\n");+ os.put_string (@"<italic_angle>$(round(font.italic_angle))</italic_angle>\n"); os.put_string (@"<units_per_em>$(font.units_per_em)</units_per_em>\n"); os.put_string (@"<trademark>$(Markup.escape_text (font.trademark))</trademark>\n"); os.put_string (@"<manufacturer>$(Markup.escape_text (font.manufacturer))</manufacturer>\n");@@ -852,6 +853,10 @@ class BirdFontFile : GLib.Object { font.weight = int.parse (t.get_content ()); } + if (t.get_name () == "italic_angle") {+ font.italic_angle = double.parse (t.get_content ());+ }+ if (t.get_name () == "units_per_em") { font.units_per_em = int.parse (t.get_content ()); }@@ -24,6 +24,7 @@ public class DescriptionDisplay : TableLayout { CheckBox bold; CheckBox italic; TextArea weight;+ TextArea italic_angle; TextArea full_name; TextArea unique_id; TextArea version;@@ -50,6 +51,7 @@ public class DescriptionDisplay : TableLayout { name = new LineTextArea (label_size); style = new LineTextArea (label_size); weight = new LineTextArea (label_size);+ italic_angle = new LineTextArea (label_size); full_name = new LineTextArea (label_size); unique_id = new LineTextArea (label_size); version = new LineTextArea (label_size);@@ -125,6 +127,21 @@ public class DescriptionDisplay : TableLayout { }); widgets.add (weight); focus_ring.add (weight);++ /*+ Italic angle in counter-clockwise degrees from the vertical. Zero+ for upright text, negative for text that leans to the right (forward).+ */++ widgets.add (new Text (t_("Italic angle, use negative values for text that leans to the right."), label_size, label_margin));+ italic_angle.margin_bottom = margin;+ italic_angle.set_text (Doubles.round (font.italic_angle));+ italic_angle.text_changed.connect ((t) => {+ font.set_italic_angle (t);+ font.touch ();+ });+ widgets.add (italic_angle);+ focus_ring.add (italic_angle); widgets.add (new Text (t_("Full Name (Name and Style)"), label_size, label_margin)); full_name.margin_bottom = margin;@@ -87,6 +87,7 @@ public class Font : GLib.Object { public bool bold = false; public bool italic = false; public int weight = 400;+ public double italic_angle = 0; public bool initialised = true; @@ -294,6 +295,10 @@ public class Font : GLib.Object { } } + public void set_italic_angle (string a) {+ italic_angle = double.parse (a);+ }+ public string get_weight () { return @"$weight"; }@@ -629,7 +629,18 @@ public class FontData : Object { add (fd.read ()); } }- ++ public static int32 to_fixed (double d) {+ int32 val = (int32) Math.floor (d);+ int32 mant = (int32) Math.floor (0x10000 * (d - val));+ val = (val << 16) | mant;+ return val;+ }++ public static double from_fixed (int32 val) {+ return val / 65536.0;+ }+ public void dump () { for (uint32 i = 0; i < length_with_padding (); i++) { stdout.printf ("%x " , table_data[i]);@@ -1078,7 +1078,20 @@ public class PostTable : OtfTable { StringBuilder name; fd.add_fixed (0x00020000); // Version- fd.add_fixed (0x00000000); // italicAngle++ Font font = OpenFontFormatWriter.get_current_font ();+ + if (!font.italic) {+ if (font.italic_angle != 0) {+ printd ("Italic angle set to $(font.italic_angle) but the italic checkbox is not ticked.");+ }+ + fd.add_fixed (0x00000000); // italicAngle+ } else {+ int angle = FontData.to_fixed (font.italic_angle);+ fd.add_32 (angle);+ }+ fd.add_short (-2); // underlinePosition fd.add_short (1); // underlineThickness@@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. """ -VERSION = '2.31.0'+VERSION = '2.32.0' SO_VERSION_MAJOR = '36' SO_VERSION_MINOR = '0' SO_VERSION = SO_VERSION_MAJOR + '.' + SO_VERSION_MINOR