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

descender is assumed to be negative, but zero should be allowed #357

Closed
skreborn opened this issue Sep 29, 2018 · 1 comment
Closed

descender is assumed to be negative, but zero should be allowed #357

skreborn opened this issue Sep 29, 2018 · 1 comment
Labels

Comments

@skreborn
Copy link

skreborn commented Sep 29, 2018

Expected Behavior

The Material Icons font to be usable with new Font({ ... }).

Current Behavior

The font can not be used, because the constructor throws an error:

Uncaught (in promise) When creating a new Font object, descender is required.

Possible Solution

The bug occurs because Font expects descender to be non-zero, while it is a valid value. A simple fix would be to change the checks as follows:

checkArgument(typeof options.descender === 'number', 'When creating a new Font object, descender is required.');
checkArgument(options.descender <= 0, 'Descender should be negative or zero (e.g. -512).');

Although highly unlikely, I suppose it would also be correct to do the same with ascender:

checkArgument(typeof options.ascender === 'number', 'When creating a new Font object, ascender is required.');

Steps to Reproduce (for bugs)

const opentype = require('opentype.js');

fetch('material-icons.otf')
  .then(response => response.arrayBuffer())
  .then(buffer => {
    const font = opentype.parse(buffer);

    new opentype.Font({
      familyName: 'Material Icons',
      styleName: font.names.fontSubfamily.en,
      unitsPerEm: font.unitsPerEm,
      ascender: font.ascender,
      // While `parse` correctly uses zero as a value, `Font` won't accept it
      descender: font.descender,
      glyphs: []
    })
  });

Context

The font is read correctly in the playground and the inspector displays its descender to be zero, as expected, but the library version doesn't produce the same results, unfortunately.

Your Environment

  • Version used: 0.8.0
  • Font used: Material Icons
@Connum Connum added the bug label Oct 30, 2023
@Connum
Copy link
Contributor

Connum commented Oct 30, 2023

This was already fixed some time ago via #422

@Connum Connum closed this as completed Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants