The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Remove regular form full name for the regular style

These changes was commited to the Birdfont repository Sat, 17 Oct 2015 13:43:38 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 17 Oct 2015 13:43:38 +0000 (15:43 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Sat, 17 Oct 2015 13:43:38 +0000 (15:43 +0200)
commit 06e5ea735ae8a3ca9b7d2e2d075f7f7ba36b0ab2
tree f6036c0f3897f8969901dc9c25825acb1c5c87ba
parent 2028417fa0c5879e15dfddc5010e5a75897cd98f
Remove regular form full name for the regular style
This is a common error.

libbirdfont/OpenFontFormat/NameTable.vala
--- a/libbirdfont/OpenFontFormat/NameTable.vala +++ b/libbirdfont/OpenFontFormat/NameTable.vala @@ -148,7 +148,18 @@ public string validate_name (string s) { return name_validation (s, true); } + + public string validate_full_name (string s) { + string n = name_validation (s, true); + string regular_suffix = " Regular"; + if (n.has_suffix (regular_suffix)) { + n = n.substring (0, n.length - regular_suffix.length); + } + + return n; + } + public static string name_validation (string s, bool allow_space, int max_length = 27) { @@ -157,7 +168,7 @@ unichar c; StringBuilder name = new StringBuilder (); - n = s; + n = s.strip (); ccount = n.char_count (); // truncate strings longer than 28 characters for (int i = 0; i < ccount && i < max_length; i++) { @@ -233,7 +244,7 @@ text.add (validate_name (font.unique_identifier)); type.add (UNIQUE_IDENTIFIER); - text.add (validate_name (font.full_name)); + text.add (validate_full_name (font.full_name)); type.add (FULL_FONT_NAME); text.add (font.version); @@ -242,13 +253,13 @@ text.add (validate_ps_name (font.postscript_name)); type.add (POSTSCRIPT_NAME); - text.add (validate_ps_name (font.trademark)); + text.add (font.trademark); type.add (TRADE_MARK); - text.add (validate_ps_name (font.manufacturer)); + text.add (font.manufacturer); type.add (MANUFACTURER); - text.add (validate_ps_name (font.designer)); + text.add (font.designer); type.add (DESIGNER); text.add (font.description);