Skip to content

extractor.exceptions.ExtractorError: There was an error reading the OTF file. #75

@jansindl3r

Description

@jansindl3r

I get an error when extracting some fonts, like this one "JunigardenSerif_PERSONAL_USE_ONLY.otf"

https://www.dafont.com/de/junigarden-swash.font

I use this library in a plugin, when it's installed locally it works fine, but when my plugin is installed from pypi. It gives an error. I installed your library as editable and see that baseAnchor can sometimes be None.

Here is my plugin
https://github.com/no-design-foundry/filters-rasterizer

    for baseRecordIndex, baseRecord in enumerate(subtable.BaseArray.BaseRecord if subtableIsType4 else subtable.Mark2Array.Mark2Record):
        baseAnchor = baseRecord.BaseAnchor[0] if subtableIsType4 else baseRecord.Mark2Anchor[0]
        anchors["baseAnchors"].update({baseCoverage[baseRecordIndex]: {"x": baseAnchor.XCoordinate, "y": baseAnchor.YCoordinate}})

Here is a proof when I print baseAnchor

<fontTools.ttLib.tables.otTables.Anchor object at 0x11052ae10>
<fontTools.ttLib.tables.otTables.Anchor object at 0x11052af90>
<fontTools.ttLib.tables.otTables.Anchor object at 0x11052ded0>
<fontTools.ttLib.tables.otTables.Anchor object at 0x11052e090>
None

then of course this error comes up

Traceback (most recent call last):
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/__init__.py", line 61, in extractUFO
    func(
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 72, in extractFontFromOpenType
    extractAnchors(source, destination)
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 1106, in extractAnchors
    anchorGroups = _gatherAnchorDataFromLookups(gpos, scriptOrder)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 1132, in _gatherAnchorDataFromLookups
    anchorsForThisLookup = _gatherAnchorsForLookup(gpos, lookupIndex)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 1159, in _gatherAnchorsForLookup
    subtableAnchors = _handleAnchorLookupType4Format1(subtable)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 1185, in _handleAnchorLookupType4Format1
    anchors["baseAnchors"].update({baseCoverage[baseRecordIndex]: {"x": baseAnchor.XCoordinate, "y": baseAnchor.YCoordinate}})
                                                                        ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'XCoordinate'
Traceback (most recent call last):
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/__init__.py", line 61, in extractUFO
    func(
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 72, in extractFontFromOpenType
    extractAnchors(source, destination)
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 1106, in extractAnchors
    anchorGroups = _gatherAnchorDataFromLookups(gpos, scriptOrder)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 1132, in _gatherAnchorDataFromLookups
    anchorsForThisLookup = _gatherAnchorsForLookup(gpos, lookupIndex)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 1159, in _gatherAnchorsForLookup
    subtableAnchors = _handleAnchorLookupType4Format1(subtable)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/formats/opentype.py", line 1185, in _handleAnchorLookupType4Format1
    anchors["baseAnchors"].update({baseCoverage[baseRecordIndex]: {"x": baseAnchor.XCoordinate, "y": baseAnchor.YCoordinate}})
                                                                        ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'XCoordinate'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/js/Desktop/debug_david/.venv/bin/ndf_rasterizer", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/js/Desktop/debug_david/.venv/lib/python3.11/site-packages/rasterizer/rasterizer.py", line 310, in main
    extractUFO(input_file, ufo)
  File "/Users/js/Desktop/debug_david/extractor/Lib/extractor/__init__.py", line 75, in extractUFO
    raise ExtractorError(
extractor.exceptions.ExtractorError: There was an error reading the OTF file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions