Skip to content

Glyphs 3, attempt 3#652

Closed
simoncozens wants to merge 101 commits intogooglefonts:mainfrom
simoncozens:glyphs3-try3
Closed

Glyphs 3, attempt 3#652
simoncozens wants to merge 101 commits intogooglefonts:mainfrom
simoncozens:glyphs3-try3

Conversation

@simoncozens
Copy link
Collaborator

No description provided.

)

_classesForName = {
".appVersion": str,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shouldn't be here, my git client went mad.

@simoncozens
Copy link
Collaborator Author

There's obviously now a lot of duplication between the add_parser lines and the _classesForName. But I will start working on the writer end soon, at which points _classesForName and _keyOrder will go away.

@anthrotype
Copy link
Member

wait, are you no longer using openstep-plist? That'd be a bummer.. It's super fast, and I made it for this very purpose.

@simoncozens
Copy link
Collaborator Author

Yeah, not until this passes:

def test_roundtrip():
    infile = "tests/data/GlyphsFileFormatv3.glyphs"

    with open(infile, "r", encoding="utf-8") as fp:
        glyphs = fp.read()
        data = openstep_plist.loads(glyphs, use_numbers=True)
        out = openstep_plist.dumps(data, indent=0)
        assert glyphs == out

@simoncozens
Copy link
Collaborator Author

Third time's a charm, I think. I've made more progress in one afternoon than in the past week.

@simoncozens simoncozens reopened this Dec 15, 2020
@anthrotype
Copy link
Member

anthrotype commented Dec 16, 2020

where can I find that file you mentioned "tests/data/GlyphsFileFormatv3.glyphs"? (it's not in your PR branch)

@khaledhosny
Copy link
Collaborator

Given the lack of manpower, I’d take the heavy handed approach of testing this branch with a big collection of Glyphs 2 files, if nothing breaks then it is good and merge. Given that Noto is the original driving force behind glyphsLib, then probably that is a good collection to test with. If this is fine, I can try doing that.

@simoncozens
Copy link
Collaborator Author

To me the whole point of having a regression test suite is to give you confidence that new changes don’t introduce regressions in behaviour that you care about. If you don’t think the test suite is adequate and you don’t trust it to do that, by all means add new test cases.

@madig
Copy link
Collaborator

madig commented May 2, 2021

I have no idea if the existing test suite really covers everything that is relevant, so if someone can spend some time giving this PR a good thrashing with various Glyphs.app files, that'd help.

@khaledhosny
Copy link
Collaborator

I tried to build noto fonts, but like have of the fonts don’t even build with its current setup, so I’m giving up.

@madig
Copy link
Collaborator

madig commented May 12, 2021

You mean Noto does not build from source right now?

@khaledhosny
Copy link
Collaborator

Yes, the first font that fails is the N'ko font, but if you delete it other fonts will fail

@madig
Copy link
Collaborator

madig commented May 12, 2021

That's funny. Their CI seems to be unhinged. Maybe file an issue? https://github.com/googlefonts/noto-source/issues

@madig madig closed this May 12, 2021
@madig madig reopened this May 12, 2021
@moyogo
Copy link
Collaborator

moyogo commented May 12, 2021

Running build src/NotoSansNKo/NotoSansNKo.glyphs works for me, with this PR as well.
@khaledhosny What commands did you run?

@khaledhosny
Copy link
Collaborator

I used ./build all, it stopped with:

==== building src/NotoSansNKo/NotoSansNKo.plist ====
INFO:fontmake.font_project:Building master UFOs and designspace from Glyphs source
INFO:glyphsLib.classes:Parsing "src/NotoSansNKo/NotoSansNKo.glyphs" file into <GSFont>
INFO:fontmake.font_project:Building OTF for NotoSansNKo-Regular
INFO:ufo2ft:Pre-processing glyphs
INFO:ufo2ft.filters.base:Running DecomposeComponentsFilter on NotoSansNKo-Regular
INFO:ufo2ft.filters.base:Running RemoveOverlapsFilter on NotoSansNKo-Regular
INFO:ufo2ft:Building OpenType tables
fontmake: Error: In 'src/NotoSansNKo/NotoSansNKo.glyphs' -> 'master_ufo/NotoSansNKo-Regular.designspace' -> 'master_ufo/NotoSansNKo-Regular.ufo': Compiling UFO failed: (b'nko', 'str', 'ScriptRecord[0]', 'ScriptList')
INFO:fontmake.font_project:Building master UFOs and designspace from Glyphs source
INFO:glyphsLib.classes:Parsing "src/NotoSansNKo/NotoSansNKo.glyphs" file into <GSFont>
INFO:fontmake.font_project:Interpolating master UFOs from designspace
INFO:fontmake.font_project:Generating instance UFO for "Noto Sans NKo Regular"
INFO:fontmake.font_project:Building OTF for NotoSansNKo-Regular
INFO:ufo2ft:Pre-processing glyphs
INFO:ufo2ft.filters.base:Running DecomposeComponentsFilter on NotoSansNKo-Regular
INFO:ufo2ft.filters.base:Running RemoveOverlapsFilter on NotoSansNKo-Regular
INFO:ufo2ft:Building OpenType tables
INFO:ufo2ft.postProcessor:Subroutinizing CFF table with cffsubr
INFO:fontTools.varLib:Axes:
[{'default': 400.0,
  'hidden': False,
  'labelNames': {'en': 'Weight'},
  'map': [(400.0, 100.0)],
  'maximum': 400.0,
  'minimum': 400.0,
  'name': 'Weight',
  'tag': 'wght'}]
INFO:fontTools.varLib:Internal master locations:
[{'Weight': 100.0}]
INFO:fontTools.varLib:Internal axis supports:
{'Weight': [100.0, 100.0, 100.0]}
INFO:fontTools.varLib:Normalized master locations:
[{'Weight': 0.0}]
INFO:fontTools.varLib:Index of base master: 0
INFO:fontTools.varLib.interpolate_layout:Building interpolated font
INFO:fontTools.varLib.interpolate_layout:Loading master fonts
fontmake: Error: In 'src/NotoSansNKo/NotoSansNKo.glyphs' -> 'master_ufo/NotoSansNKo-Regular.designspace': Generating fonts from Designspace failed: Invalid master path: 'master_otf/NotoSansNKo-Regular.otf'

@khaledhosny
Copy link
Collaborator

./build src/NotoSansNKo/NotoSansNKo.glyphs works, but ./build src/NotoSansNKo/NotoSansNKo.plist (which is what all calls) fails with the above error.

@moyogo
Copy link
Collaborator

moyogo commented May 13, 2021

Thanks @khaledhosny. I should have seen that.

@jenskutilek
Copy link
Contributor

I have quite a collection of Glyphs 2 and 3 files, but most of them have TrueType hints, so glyphsLib bails out when trying to build them ...

@simoncozens
Copy link
Collaborator Author

glyphsLib or fontmake? If there’s a problem reading the hints with this branch, please let me know.

@jenskutilek
Copy link
Contributor

@simoncozens When I try to use glyphs2ufo on this file, I get this traceback. Not sure how to pinpoint what specific piece of data causes it ...

$ glyphs2ufo Sudo.glyphs
Traceback (most recent call last):
  File "/Users/jens/Code/glyphsLib3Test/env/bin/glyphs2ufo", line 33, in <module>
    sys.exit(load_entry_point('glyphsLib', 'console_scripts', 'glyphs2ufo')())
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/cli.py", line 228, in _glyphs2ufo_entry_point
    return main(args)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/cli.py", line 189, in main
    return options.func(options)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/cli.py", line 208, in glyphs2ufo
    glyphsLib.build_masters(
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/__init__.py", line 104, in build_masters
    font = GSFont(filename)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/classes.py", line 3698, in __init__
    p.parse_into_object(self, fp.read())
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 63, in parse_into_object
    i = self._parse_dict_into_object(res, text, 1)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 166, in _parse_dict_into_object
    result = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 103, in _parse
    return self._parse_list(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 193, in _parse_list
    list_item, i = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 97, in _parse
    return self._parse_dict(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 150, in _parse_dict
    i = self._parse_dict_into_object(res, text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 166, in _parse_dict_into_object
    result = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 103, in _parse
    return self._parse_list(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 193, in _parse_list
    list_item, i = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 97, in _parse
    return self._parse_dict(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 150, in _parse_dict
    i = self._parse_dict_into_object(res, text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 166, in _parse_dict_into_object
    result = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 103, in _parse
    return self._parse_list(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 193, in _parse_list
    list_item, i = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 97, in _parse
    return self._parse_dict(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 150, in _parse_dict
    i = self._parse_dict_into_object(res, text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 166, in _parse_dict_into_object
    result = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 103, in _parse
    return self._parse_list(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 193, in _parse_list
    list_item, i = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 125, in _parse
    value = self.current_type(value)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/types.py", line 129, in __init__
    self.value = self.fromString(value)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/types.py", line 96, in fromString
    return [parse_float_or_int(i) for i in self.regex.match(src).groups()]
AttributeError: 'NoneType' object has no attribute 'groups'

When I remove userData and hinting, I get a different error:

Traceback (most recent call last):
  File "/Users/jens/Code/glyphsLib3Test/env/bin/glyphs2ufo", line 33, in <module>
    sys.exit(load_entry_point('glyphsLib', 'console_scripts', 'glyphs2ufo')())
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/cli.py", line 228, in _glyphs2ufo_entry_point
    return main(args)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/cli.py", line 189, in main
    return options.func(options)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/cli.py", line 208, in glyphs2ufo
    glyphsLib.build_masters(
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/__init__.py", line 104, in build_masters
    font = GSFont(filename)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/classes.py", line 3698, in __init__
    p.parse_into_object(self, fp.read())
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 64, in parse_into_object
    i = self._parse_dict_into_object(res, text, 1)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 167, in _parse_dict_into_object
    result = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 104, in _parse
    return self._parse_list(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 194, in _parse_list
    list_item, i = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 98, in _parse
    return self._parse_dict(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 151, in _parse_dict
    i = self._parse_dict_into_object(res, text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 167, in _parse_dict_into_object
    result = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 104, in _parse
    return self._parse_list(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 194, in _parse_list
    list_item, i = self._parse(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 98, in _parse
    return self._parse_dict(text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 151, in _parse_dict
    i = self._parse_dict_into_object(res, text, i)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/parser.py", line 170, in _parse_dict_into_object
    res[name], i = result
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/classes.py", line 3107, in __setitem__
    super().__setitem__(key, value)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/classes.py", line 366, in __setitem__
    setattr(self, key, value)
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/classes.py", line 3213, in <lambda>
    lambda self, value: LayerGuideLinesProxy(self).setter(value),
  File "/Users/jens/Code/glyphsLib3/Lib/glyphsLib/classes.py", line 986, in setter
    value._parent = self._owner
AttributeError: 'str' object has no attribute '_parent'

@jenskutilek
Copy link
Contributor

Oh, I’m in a special kind of Glyphs hell ;) In Sudo there are some TT hints that can not be seen in TT instructor nor deleted by setting layer.hints = []

@simoncozens
Copy link
Collaborator Author

Thanks for this. I deleted the hints by hand and it converted fine, so I will see what's going on with the hint parsing code.

@khaledhosny
Copy link
Collaborator

I gave up trying to build Noto and opted for something less ambitious, I changed the build script to output UFO from fontmake instead and compared the output with glyphsLib main and this branch.

I’m getting this warning with all fonts:

glyphsLib/classes.py:1707: UserWarning: GSFontMaster metric ascender accessed without an associated font!
  warnings.warn(
glyphsLib/classes.py:1707: UserWarning: GSFontMaster metric cap height accessed without an associated font!
  warnings.warn(
glyphsLib/classes.py:1707: UserWarning: GSFontMaster metric descender accessed without an associated font!
  warnings.warn(
glyphsLib/classes.py:1707: UserWarning: GSFontMaster metric x-height accessed without an associated font!
  warnings.warn(

Here are some of the common diff’s I’m seeing:

diff --git a/master_ufo/Cousine-Bold.ufo/lib.plist b/master_ufo/Cousine-Bold.ufo/lib.plist
index 2582c29164..342aec4533 100644
--- a/master_ufo/Cousine-Bold.ufo/lib.plist
+++ b/master_ufo/Cousine-Bold.ufo/lib.plist
@@ -18,7 +18,7 @@
     <key>com.schriftgestaltung.appVersion</key>
     <string>1277</string>
     <key>com.schriftgestaltung.customParameter.GSFont.disablesAutomaticAlignment</key>
-    <true/>
+    <integer>1</integer>
     <key>com.schriftgestaltung.customParameter.GSFont.useNiceNames</key>
     <integer>0</integer>
     <key>com.schriftgestaltung.customParameter.GSFontMaster.customValue</key>
diff --git a/master_ufo/NotoKufiArabic-Black.ufo/lib.plist b/master_ufo/NotoKufiArabic-Black.ufo/lib.plist
index bacb012519..c270714eae 100644
--- a/master_ufo/NotoKufiArabic-Black.ufo/lib.plist
+++ b/master_ufo/NotoKufiArabic-Black.ufo/lib.plist
@@ -17,15 +17,6 @@
     <string>1350</string>
     <key>com.schriftgestaltung.customName</key>
     <string>Black</string>
-    <key>com.schriftgestaltung.customParameter.GSFont.Axes</key>
-    <array>
-      <dict>
-        <key>Name</key>
-        <string>Weight</string>
-        <key>Tag</key>
-        <string>wght</string>
-      </dict>
-    </array>
     <key>com.schriftgestaltung.customParameter.GSFont.Enforce Compatibility Check</key>
     <integer>1</integer>
     <key>com.schriftgestaltung.customParameter.GSFont.disablesAutomaticAlignment</key>
diff --git a/master_ufo/NotoLoopedLao-Regular.ufo/glyphs/aV_owel-lao.glif b/master_ufo/NotoLoopedLao-Regular.ufo/glyphs/aV_owel-lao.glif
index 673edf0b65..946f734f3e 100644
--- a/master_ufo/NotoLoopedLao-Regular.ufo/glyphs/aV_owel-lao.glif
+++ b/master_ufo/NotoLoopedLao-Regular.ufo/glyphs/aV_owel-lao.glif
@@ -96,7 +96,7 @@
       <array>
         <dict>
           <key>horizontal</key>
-          <true/>
+          <integer>1</integer>
           <key>options</key>
           <integer>0</integer>
           <key>origin</key>
@@ -116,7 +116,7 @@
         </dict>
         <dict>
           <key>horizontal</key>
-          <true/>
+          <integer>1</integer>
           <key>options</key>
           <integer>0</integer>
           <key>origin</key>
diff --git a/master_ufo/NotoSans-Condensed.ufo/glyphs/ostroke-blackletter.glif b/master_ufo/NotoSans-Condensed.ufo/glyphs/ostroke-blackletter.glif
index 79d52763b7..3d0c8b559d 100644
--- a/master_ufo/NotoSans-Condensed.ufo/glyphs/ostroke-blackletter.glif
+++ b/master_ufo/NotoSans-Condensed.ufo/glyphs/ostroke-blackletter.glif
@@ -34,7 +34,7 @@
       <string>Lowercase</string>
       <key>com.schriftgestaltung.componentsLocked</key>
       <array>
-        <true/>
+        <integer>1</integer>
       </array>
     </dict>
   </lib>

(So far, this true/1 change accounts for most of the diff)

@khaledhosny
Copy link
Collaborator

diff --git a/master_ufo/NotoSansIV-Italic.designspace b/master_ufo/NotoSansIV-Italic.designspace
index 7fd075a26d..6911400c9c 100644
--- a/master_ufo/NotoSansIV-Italic.designspace
+++ b/master_ufo/NotoSansIV-Italic.designspace
@@ -4,13 +4,11 @@
     <axis tag="wght" name="Weight" minimum="100" maximum="100" default="100">
       <map input="100" output="26"/>
     </axis>
-    <axis tag="wdth" name="Width" minimum="100" maximum="100" default="100"/>
   </axes>
   <sources>
     <source filename="NotoSansIV-LightItalic.ufo" name="Noto Sans IV Light Italic" familyname="Noto Sans IV" stylename="Light Italic">
       <location>
         <dimension name="Weight" xvalue="26"/>
-        <dimension name="Width" xvalue="100"/>
       </location>
     </source>
     <source filename="NotoSansIV-Italic.ufo" name="Noto Sans IV Italic" familyname="Noto Sans IV" stylename="Italic">
@@ -20,43 +18,36 @@
       <info copy="1"/>
       <location>
         <dimension name="Weight" xvalue="90"/>
-        <dimension name="Width" xvalue="100"/>
       </location>
     </source>
     <source filename="NotoSansIV-SemiBoldItalic.ufo" name="Noto Sans IV SemiBold Italic" familyname="Noto Sans IV" stylename="SemiBold Italic">
       <location>
         <dimension name="Weight" xvalue="151"/>
-        <dimension name="Width" xvalue="100"/>
       </location>
     </source>
     <source filename="NotoSansIV-BoldItalic.ufo" name="Noto Sans IV Bold Italic" familyname="Noto Sans IV" stylename="Bold Italic">
       <location>
         <dimension name="Weight" xvalue="190"/>
-        <dimension name="Width" xvalue="100"/>
       </location>
     </source>
     <source filename="NotoSansIV-CondensedLightItalic.ufo" name="Noto Sans IV Condensed Light Italic" familyname="Noto Sans IV" stylename="Condensed Light Italic">
       <location>
         <dimension name="Weight" xvalue="26"/>
-        <dimension name="Width" xvalue="70"/>
       </location>
     </source>
     <source filename="NotoSansIV-CondensedItalic.ufo" name="Noto Sans IV Condensed Italic" familyname="Noto Sans IV" stylename="Condensed Italic">
       <location>
         <dimension name="Weight" xvalue="90"/>
-        <dimension name="Width" xvalue="70"/>
       </location>
     </source>
     <source filename="NotoSansIV-CondensedSemiBoldItalic.ufo" name="Noto Sans IV Condensed SemiBold Italic" familyname="Noto Sans IV" stylename="Condensed SemiBold Italic">
       <location>
         <dimension name="Weight" xvalue="151"/>
-        <dimension name="Width" xvalue="70"/>
       </location>
     </source>
     <source filename="NotoSansIV-CondensedBoldItalic.ufo" name="Noto Sans IV Condensed Bold Italic" familyname="Noto Sans IV" stylename="Condensed Bold Italic">
       <location>
         <dimension name="Weight" xvalue="190"/>
-        <dimension name="Width" xvalue="70"/>
       </location>
     </source>
   </sources>
@@ -64,7 +55,6 @@
     <instance name="Noto Sans IV Thin Italic" familyname="Noto Sans IV" stylename="Thin Italic" filename="../instance_ufo/NotoSansIV-ThinItalic.ufo" stylemapfamilyname="Noto Sans IV Thin" stylemapstylename="italic">
       <location>
         <dimension name="Weight" xvalue="26"/>
-        <dimension name="Width" xvalue="100"/>
       </location>
       <kerning/>
       <info/>

@khaledhosny
Copy link
Collaborator

diff --git a/master_ufo/NotoTraditionalNushu.designspace b/master_ufo/NotoTraditionalNushu.designspace
index 4441f86bf9..8fe320d152 100644
--- a/master_ufo/NotoTraditionalNushu.designspace
+++ b/master_ufo/NotoTraditionalNushu.designspace
@@ -2,9 +2,7 @@
 <designspace format="4.1">
   <axes>
     <axis tag="wght" name="Weight" minimum="300" maximum="700" default="400"/>
-    <axis tag="wdth" name="Width" minimum="100" maximum="100" default="100">
-      <map input="100" output="5"/>
-    </axis>
+    <axis tag="wdth" name="Width" minimum="5" maximum="5" default="5"/>
   </axes>
   <sources>
     <source filename="NotoTraditionalNushu-Light.ufo" name="Noto Traditional Nushu Light" familyname="Noto Traditional Nushu" stylename="Light">

The rest of the diffs are instances of the examples above.

@simoncozens
Copy link
Collaborator Author

5102f8a might fix the diffs you saw above.

@madig madig mentioned this pull request Jun 24, 2021
@simoncozens
Copy link
Collaborator Author

-> #691

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants