Skip to content

getEnglishName('fontFamily') returns undefined, font.names.macintosh is incomplete #570

Open
@Connum

Description

@Connum

Expected Behavior

The font download shouldn't fail if font.getEnglishName('fontFamily') returns undefined, but even more so, font.getEnglishName('fontFamily') shouldn't return undefined in the first place.

Current Behavior

For some fonts font.download() fails because font.getEnglishName('fontFamily') returns undefined

Possible Solution

The issues seems to be related to #542. The name table.names.macintosh contains several numeric IDs for, but none of the regular entries. In getEnglishName() we should probably do this (we can't use optional chaining because it cannot be transpiled currently, but just to get the idea):

const translations = (this.names?.unicode[name] || this.names?.macintosh[name] || this.names?.windows[name]);

Also in names.js,

                let platform = name[platformName];
                if (platform === undefined) {
                    platform = name[platformName] = {};
                }
                let translations = platform[property];
                if (translations === undefined) {
                    translations = platform[property] = {};
                }

The name/platform shouldn't be initialized to an empty object, but the default name properties should be copied from one of the existing ones.

But also it shouldn't ever happen that the names objects are in such an irregular state.

Steps to Reproduce (for bugs)

  1. Download this font and load into opentype.js
  2. call font.getEnglishName('fontFamily')
  3. call font.download()

Your Environment

  • Version used: current master
  • Font used: Selawik-variable.ttf
  • Browser Name and version: -
  • Operating System and version (desktop or mobile): -
  • Link to your project: -

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions