Open guidoferreyra opened 2 years ago
By changing
https://github.com/foliojs/fontkit/blob/417af0c79c5664271a07a783574ec7fac7ebad0c/src/tables/name.js#L79
and
https://github.com/foliojs/fontkit/blob/417af0c79c5664271a07a783574ec7fac7ebad0c/src/tables/name.js#L85
to:
record.nameID >= 256 || record.nameID == 2 || record.nameID == 17
will solve the issue.
Is there a reason to create the name array fontFeatures
? Why when looking for a name just dont search on the full list?
I have the same problem. Glyphs uses nameID: 2
in some cases.
@guidoferreyra do you want to create a PR? Otherwise I can do it.
Can we get this merged?
Font Subfamily name is Name ID Code 2. This means you could search and replace any named instances with nameID: 2
with the Subfamily name.
also getting this error. — if there is a fix, please merge 🙏
I also run into this issue, it is actually quite common. The fix PR above seem to have an error at least in the PR description, so please double check before merge: https://github.com/foliojs/fontkit/pull/317#issuecomment-1726714841
This also happens with other references (eg. ID 17 was known as “Preferred Subfamily”)
Have you found a work around @Typogram ?
Even just a way to lookup by name id without having to create a dictionary via https://learn.microsoft.com/en-us/typography/opentype/spec/name
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: