Commit 08ce1c3
License and other descriptive fields in TTF fonts The added fields are license, license url, trademark, manufacturer, designer, vendor url, designer url.
Changed files (4)
modifiedlibbirdfont/BirdFontFile.valamodifiedlibbirdfont/DescriptionDisplay.valamodifiedlibbirdfont/Font.valamodifiedlibbirdfont/OpenFontFormat/NameTable.vala
Diff
@@ -24,7 +24,7 @@ class BirdFontFile : GLib.Object { Font font; public static const int FORMAT_MAJOR = 2;- public static const int FORMAT_MINOR = 0;+ public static const int FORMAT_MINOR = 1; public static const int MIN_FORMAT_MAJOR = 0; public static const int MIN_FORMAT_MINOR = 0;@@ -340,8 +340,16 @@ class BirdFontFile : GLib.Object { os.put_string (@"<version>$(Markup.escape_text (font.version))</version>\n"); os.put_string (@"<description>$(Markup.escape_text (font.description))</description>\n"); os.put_string (@"<copyright>$(Markup.escape_text (font.copyright))</copyright>\n");+ 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 (@"<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");+ os.put_string (@"<designer>$(Markup.escape_text (font.designer))</designer>\n");+ os.put_string (@"<vendor_url>$(Markup.escape_text (font.vendor_url))</vendor_url>\n");+ os.put_string (@"<designer_url>$(Markup.escape_text (font.designer_url))</designer_url>\n");+ } public void write_lines (DataOutputStream os) throws GLib.Error {@@ -744,6 +752,34 @@ class BirdFontFile : GLib.Object { font.copyright = XmlParser.decode (t.get_content ()); } + if (t.get_name () == "license") {+ font.license = XmlParser.decode (t.get_content ());+ }+ + if (t.get_name () == "license_url") {+ font.license_url = XmlParser.decode (t.get_content ());+ }++ if (t.get_name () == "trademark") {+ font.trademark = XmlParser.decode (t.get_content ());+ }+ + if (t.get_name () == "manufacturer") {+ font.manufacturer = XmlParser.decode (t.get_content ());+ }+ + if (t.get_name () == "designer") {+ font.designer = XmlParser.decode (t.get_content ());+ }+ + if (t.get_name () == "vendor_url") {+ font.vendor_url = XmlParser.decode (t.get_content ());+ }+ + if (t.get_name () == "designer_url") {+ font.designer_url = XmlParser.decode (t.get_content ());+ }+ if (t.get_name () == "kerning") { parse_kerning (t); }@@ -29,6 +29,13 @@ public class DescriptionDisplay : TableLayout { TextArea version; TextArea description; TextArea copyright;+ TextArea license;+ LineTextArea license_url;+ TextArea trademark;+ LineTextArea manufacturer;+ LineTextArea designer;+ LineTextArea vendor_url;+ LineTextArea designer_url; private static bool disable_copyright = false; @@ -48,7 +55,14 @@ public class DescriptionDisplay : TableLayout { version = new LineTextArea (label_size); description = new TextArea (label_size); copyright = new TextArea (label_size);-+ license = new TextArea (label_size);+ license_url = new LineTextArea (label_size);+ trademark = new TextArea (label_size);+ manufacturer = new LineTextArea (label_size);+ designer = new LineTextArea (label_size);+ vendor_url = new LineTextArea (label_size);+ designer_url = new LineTextArea (label_size);+ headline = new Headline (t_("Name and Description")); headline.margin_bottom = 20 * MainWindow.units; widgets.add (headline);@@ -165,7 +179,87 @@ public class DescriptionDisplay : TableLayout { copyright.set_editable (!disable_copyright); widgets.add (copyright); focus_ring.add (copyright);- ++ widgets.add (new Text (t_("License"), label_size, label_margin));+ license.margin_bottom = margin;+ license.set_text (font.license);+ license.scroll.connect (scroll_event);+ license.text_changed.connect ((t) => {+ font.license = t;+ font.touch ();+ });+ license.set_editable (!disable_copyright);+ widgets.add (license);+ focus_ring.add (license);++ widgets.add (new Text (t_("License URL"), label_size, label_margin));+ license_url.margin_bottom = margin;+ license_url.set_text (font.license_url);+ license_url.scroll.connect (scroll_event);+ license_url.text_changed.connect ((t) => {+ font.license_url = t;+ font.touch ();+ });+ license_url.set_editable (!disable_copyright);+ widgets.add (license_url);+ focus_ring.add (license_url);++ widgets.add (new Text (t_("Trademark"), label_size, label_margin));+ trademark.margin_bottom = margin;+ trademark.set_text (font.trademark);+ trademark.scroll.connect (scroll_event);+ trademark.text_changed.connect ((t) => {+ font.trademark = t;+ font.touch ();+ });+ trademark.set_editable (!disable_copyright);+ widgets.add (trademark);+ focus_ring.add (trademark);++ widgets.add (new Text (t_("Manufakturer"), label_size, label_margin));+ manufacturer.margin_bottom = margin;+ manufacturer.set_text (font.manufacturer);+ manufacturer.scroll.connect (scroll_event);+ manufacturer.text_changed.connect ((t) => {+ font.manufacturer = t;+ font.touch ();+ });+ widgets.add (manufacturer);+ focus_ring.add (manufacturer);++ widgets.add (new Text (t_("Designer"), label_size, label_margin));+ designer.margin_bottom = margin;+ designer.set_text (font.designer);+ designer.scroll.connect (scroll_event);+ designer.text_changed.connect ((t) => {+ font.designer = t;+ font.touch ();+ });+ widgets.add (designer);+ focus_ring.add (designer);++ widgets.add (new Text (t_("Vendor URL"), label_size, label_margin));+ vendor_url.margin_bottom = margin;+ vendor_url.set_text (font.vendor_url);+ vendor_url.scroll.connect (scroll_event);+ vendor_url.text_changed.connect ((t) => {+ font.vendor_url = t;+ font.touch ();+ });+ widgets.add (vendor_url);+ focus_ring.add (vendor_url);++ widgets.add (new Text (t_("Designer URL"), label_size, label_margin));+ designer_url.margin_bottom = margin;+ designer_url.set_text (font.designer_url);+ designer_url.scroll.connect (scroll_event);+ designer_url.text_changed.connect ((t) => {+ font.designer_url = t;+ font.touch ();+ });+ widgets.add (designer_url);+ focus_ring.add (designer_url);+ set_focus (postscript_name); foreach (Widget w in widgets) {@@ -72,6 +72,13 @@ public class Font : GLib.Object { public string version; public string description; public string copyright;+ public string license;+ public string license_url;+ public string trademark;+ public string manufacturer;+ public string designer;+ public string vendor_url;+ public string designer_url; public bool bold = false; public bool italic = false;@@ -101,6 +108,7 @@ public class Font : GLib.Object { public Ligatures ligature_substitution; public static string? default_license = null; + public static string? default_license_url = null; public FontSettings settings; public KerningStrings kerning_strings;@@ -124,8 +132,24 @@ public class Font : GLib.Object { unique_identifier = "Typeface"; version = "Version 1.0"; description = "";- copyright = default_license != null ? ((!) default_license).dup () : "";- + copyright = "";+ license = "";+ license_url = "";+ trademark = "";+ manufacturer = "";+ designer = "";+ vendor_url = "";+ designer_url = "";+ + if (default_license != null) {+ copyright = (!) default_license;+ license = (!) default_license;+ }++ if (default_license_url != null) {+ license_url = (!) default_license_url;+ }+ glyph_cache = new GlyphTable (); glyph_name = new GlyphTable (); ligature = new GlyphTable ();@@ -187,8 +211,9 @@ public class Font : GLib.Object { return false; } - public static void set_default_license (string license) {+ public static void set_default_license (string license, string url) { default_license = license;+ default_license_url = url; } public Ligatures get_ligatures () {@@ -23,9 +23,17 @@ public class NameTable : OtfTable { public static const uint16 FULL_FONT_NAME = 4; // name + subfamily public static const uint16 VERSION = 5; public static const uint16 POSTSCRIPT_NAME = 6;+ public static const uint16 TRADE_MARK = 7;+ public static const uint16 MANUFACTURER = 8;+ public static const uint16 DESIGNER = 9; public static const uint16 DESCRIPTION = 10;+ public static const uint16 VENDOR_URL = 11;+ public static const uint16 DESIGNER_URL = 12;+ public static const uint16 LICENSE = 13;+ public static const uint16 LICENSE_URL = 14; public static const uint16 PREFERED_FAMILY = 16; public static const uint16 PREFERED_SUB_FAMILY = 17;+ Gee.ArrayList<uint16> identifiers; Gee.ArrayList<string> text;@@ -232,8 +240,29 @@ public class NameTable : OtfTable { text.add (validate_ps_name (font.postscript_name)); type.add (POSTSCRIPT_NAME); + text.add (validate_ps_name (font.trademark));+ type.add (TRADE_MARK);+ + text.add (validate_ps_name (font.manufacturer));+ type.add (MANUFACTURER);++ text.add (validate_ps_name (font.designer));+ type.add (DESIGNER);+ text.add (font.description); type.add (DESCRIPTION);++ text.add (font.vendor_url);+ type.add (VENDOR_URL);++ text.add (font.designer_url);+ type.add (DESIGNER_URL);+ + text.add (font.license);+ type.add (LICENSE);+ + text.add (font.license_url);+ type.add (LICENSE_URL); text.add (validate_name (font.name)); type.add (PREFERED_FAMILY);