Skip to content

font.namedVariations fails on some fonts #272

@guidoferreyra

Description

@guidoferreyra

When parsing some fonts and trying to get namedVariation. it throws the following error:

TypeError: Cannot read property 'en' of undefined

When printing the instance where the undefined is raised it shows the following, name is missing.
{ nameID: 2, flags: 0, coord: [ 0, 400, 100, 0 ], postscriptNameID: 6 }

I dug a bit and the issue is cause because when getting the instance name is not fnding id 2 since name.records.fontFeatures starts at ID 256. When instance name matches with font ID 2 will use that, it seems this is very common and allowed by the spec:

The subfamilyNameID field provides a name ID that can be used to obtain strings from the 'name' table that can be treated as equivalent to name ID 17 (typographic subfamily) strings for the given instance. Values of 2 or 17 can be used; otherwise, values must be greater than 255 and less than 32768. The values 2 or 17 should only be used if the named instance corresponds to the font’s default instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions