MuTsunTsai / fontfreeze

Freeze variations and features in font.
https://mutsuntsai.github.io/fontfreeze/
MIT License
119 stars 1 forks source link

AssertionError when saving if "Target feature for activation" is empty #14

Open benblank opened 2 months ago

benblank commented 2 months ago

I was trying to customize JuliaMono and, as calt was one of the features I was looking to remove and it was present in the "Target feature for activation" field, I removed it there as well. When clicking the "Generate Font!" button, an AssertionError modal appeared (see collapsed section below).

After some fiddling, I was able to isolate the problem to having an empty target feature field plus at least one feature being applied/enabled (blue checkbox). The font used didn't seem to matter, but I only had a couple of fonts handy to test with (JuliaMono and Hack).

AssertionError: (b'', 'str', 39, 'FeatureRecord[]', 'FeatureList') ```text An error occur: Traceback (most recent call last): File "", line 155, in processFont File "", line 158, in main File "/lib/python3.11/site-packages/fontTools/ttLib/ttFont.py", line 212, in save writer_reordersTables = self._save(tmp) ^^^^^^^^^^^^^^^ File "/lib/python3.11/site-packages/fontTools/ttLib/ttFont.py", line 259, in _save self._writeTable(tag, writer, done, tableCache) File "/lib/python3.11/site-packages/fontTools/ttLib/ttFont.py", line 710, in _writeTable tabledata = self.getTableData(tag) ^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.11/site-packages/fontTools/ttLib/ttFont.py", line 732, in getTableData return self.tables[tag].compile(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otBase.py", line 155, in compile self.table.compile(writer, font) File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otBase.py", line 1100, in compile conv.write(writer, font, table, value) File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otConverters.py", line 753, in write value.compile(subWriter, font) File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otBase.py", line 1062, in compile conv.writeArray(writer, font, table, value) File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otConverters.py", line 216, in writeArray self.write(writer, font, tableDict, value, i) File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otConverters.py", line 634, in write value.compile(writer, font) File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otBase.py", line 1100, in compile conv.write(writer, font, table, value) File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otConverters.py", line 423, in write writer.writeTag(value) File "/lib/python3.11/site-packages/fontTools/ttLib/tables/otBase.py", line 784, in writeTag assert len(tag) == 4, tag ^^^^^^^^^^^^^ AssertionError: (b'', 'str', 39, 'FeatureRecord[]', 'FeatureList') ```
MuTsunTsai commented 2 months ago

That's not how it works. Just mark the calt with an ❌ while leave the Target feature for activation as it is, and the font will build.

benblank commented 2 months ago

Yeah, I figured that out afterward. I was just thinking that it would be nice if there were a friendly error message saying that the target feature field shouldn't be empty rather than a stack trace. 🙂