Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fontforge generate creates bad GPOS table in NotoNaskhArabic-Regular.ttf #4675

Open
Zecknaal opened this issue Mar 19, 2021 · 8 comments
Open

Comments

@Zecknaal
Copy link

Environment:

I've tried running this from Ubuntu 16.04 (fontforge 20120731) and Ubuntu 18.04 (fontforge 20170924) with the same results.

What I am doing:

I would like to generate a font based on NotoNaskhArabic-Regular.ttf (here). I am using the following script:

#!/usr/bin/fontforge

Open("NotoNaskhArabic-Regular.ttf")
Generate("OutputFont.ttf");

Expectation:

A functionally identical font called "OutputFont.ff" is generated. If I run sfddiff against it, I would expect to see something like:

user@6a4dbed378cd:~/$ sfddiff NotoNaskhArabic-Regular.ttf OutputFont.ttf 
Copyright (c) 2000-2012 by George Williams.
 Executable based on sources from 14:57 GMT 31-Jul-2012-ML.
 Library based on sources from 14:57 GMT 31-Jul-2012.

Issue:

The generated font seems to contain many different errors. I am not a font guy so I don't fully understand the errors that I'm seeing, but they seem to be numerous and severe. If I try sfddiff I get this:

user@6a4dbed378cd:~/$ sfddiff NotoNaskhArabic-Regular.ttf OutputFont.ttf 
Copyright (c) 2000-2012 by George Williams.
 Executable based on sources from 14:57 GMT 31-Jul-2012-ML.
 Library based on sources from 14:57 GMT 31-Jul-2012.
Bad device table
Bad device table
... (~180 lines or so of "Bad device table")
Subtable extends beyond end of GPOS table
Bad device table
Bad device table
... (~180 lines or so of "Bad device table")
Subtable extends beyond end of GPOS table
The glyph named null is mapped to U+FEFF.
  But its name indicates it should be mapped to U+2400.
The glyph named null is mapped to U+FEFF.
  But its name indicates it should be mapped to U+2400.
Outline Glyphs
 Glyphs in OutputFont.ttf but not in /home/user/NotoNaskhArabic-Regular.ttf
  Glyph “.null” missing from /home/user/NotoNaskhArabic-Regular.ttf

If I try to open up the new font in the GUI application it also spends a long time "Fixing up References" and generates warnings that appear identical to the sfddiff output.

I'm not sure if this is an issue with fontforge or the Noto font. Other Noto fonts I have worked with in fontforge seem to be fine, including other Arabic fonts. I do not deeply understand the inner workings of how fonts work so I'm not sure what else to provide. It seems perfectly likely that the issue could be in the font and not in fontforge, but I'm not sure how to prove that.

@jtanx
Copy link
Contributor

jtanx commented Mar 19, 2021

Please try again with the latest version and reopen if it's still an issue, those versions are ancient.

@jtanx jtanx closed this as completed Mar 19, 2021
@Zecknaal
Copy link
Author

I built the latest fontforge from source:

Copyright (c) 2000-2021. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Version: 20201107
 Based on sources from 2021-03-19 22:37 UTC-ML-D-GDK3.
 Based on source from git with hash: 25c3b74b96c54fce5d3cafa31f9db31ca33e559f
fontforge 20201107
build date: 2021-03-19 22:37 UTC

The issue is still occurring for me. The symptoms appear the same as the original post.

@ctrlcctrlv ctrlcctrlv reopened this Mar 20, 2021
@ctrlcctrlv
Copy link
Member

The GPOS table is being written incorrectly by FontForge in this case.

[fred@laptop tmp]$ ttx OutputFont.ttf 
Dumping "OutputFont.ttf" to "OutputFont.ttx"...
Dumping 'GlyphOrder' table...
Dumping 'head' table...
Dumping 'hhea' table...
Dumping 'maxp' table...
Dumping 'OS/2' table...
Dumping 'hmtx' table...
Dumping 'cmap' table...
Dumping 'loca' table...
Dumping 'glyf' table...
Dumping 'name' table...
Dumping 'post' table...
Dumping 'gasp' table...
Dumping 'FFTM' table...
Dumping 'GDEF' table...
ERROR: An exception occurred during the decompilation of the 'GPOS' table
Traceback (most recent call last):
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/ttFont.py", line 372, in __getitem__
    return self.tables[tag]
KeyError: 'GPOS'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/ttFont.py", line 391, in __getitem__
    table.decompile(data, self)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 41, in decompile
    self.table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 640, in decompile
    table[conv.name] = conv.read(reader, font, table)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 547, in read
    table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 636, in decompile
    table[conv.name] = conv.readArray(reader, font, table, countValue)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 167, in readArray
    l.append(self.read(reader, font, tableDict))
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 547, in read
    table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 636, in decompile
    table[conv.name] = conv.readArray(reader, font, table, countValue)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 167, in readArray
    l.append(self.read(reader, font, tableDict))
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 547, in read
    table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 640, in decompile
    table[conv.name] = conv.read(reader, font, table)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 547, in read
    table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 636, in decompile
    table[conv.name] = conv.readArray(reader, font, table, countValue)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 167, in readArray
    l.append(self.read(reader, font, tableDict))
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 547, in read
    table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 636, in decompile
    table[conv.name] = conv.readArray(reader, font, table, countValue)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 167, in readArray
    l.append(self.read(reader, font, tableDict))
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 434, in read
    table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 636, in decompile
    table[conv.name] = conv.readArray(reader, font, table, countValue)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 167, in readArray
    l.append(self.read(reader, font, tableDict))
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 547, in read
    table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 640, in decompile
    table[conv.name] = conv.read(reader, font, table)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 547, in read
    table.decompile(reader, font)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 640, in decompile
    table[conv.name] = conv.read(reader, font, table)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otConverters.py", line 252, in read
    return reader.readUShort()
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 145, in readUShort
    return self.readValue("H", staticSize=2)
  File "/home/fred/.local/lib/python3.9/site-packages/fonttools-4.19.2.dev0-py3.9.egg/fontTools/ttLib/tables/otBase.py", line 140, in readValue
    value, = struct.unpack(f">{typecode}", self.data[pos:newpos])
struct.error: ('unpack requires a buffer of 2 bytes', 'StartSize', 'XDeviceTable', 'LigatureAnchor', 'ComponentRecord', 'LigatureAttach', 'LigatureArray', 'SubTable', 'Lookup', 'LookupList')
Dumping 'GPOS' table...
Dumping 'GSUB' table...

@ctrlcctrlv ctrlcctrlv changed the title fontforge generate creates bad NotoNaskhArabic-Regular.ttf fontforge generate creates bad GPOS table in NotoNaskhArabic-Regular.ttf Mar 20, 2021
@Zecknaal
Copy link
Author

Zecknaal commented Apr 1, 2021

I'm not sure if this is helpful in identifying the font as the culprit, but if I run sfddiff against just the base font it reports an error:

user:$ sfddiff NotoNaskhArabic-Regular.ttf NotoNaskhArabic-Regular.ttf 
Copyright (c) 2000-2021. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Version: 20201107
 Based on sources from 2021-03-19 22:37 UTC-ML-D-GDK3.
 Based on source from git with hash: 25c3b74b96c54fce5d3cafa31f9db31ca33e559f
The glyph named null is mapped to U+FEFF.
  But its name indicates it should be mapped to U+2400.

So maybe either the font is bad or fontforge is having issues reading this font, which then makes generating it impossible?

@ctrlcctrlv
Copy link
Member

The GPOS table is definitely valid in the original font. I'm certain this is a FontForge bug.

@Zecknaal
Copy link
Author

Any chance this issue will get attention some time soon?

@ctrlcctrlv
Copy link
Member

Not from me, sorry.

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

No branches or pull requests

4 participants
@Zecknaal @ctrlcctrlv @jtanx and others