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

Feat: loadFromUrl supports Node.js environment #503

Merged
merged 17 commits into from
Nov 15, 2023
Merged
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions test/opentypeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ describe('opentype.js', function() {
});
});

it('can load a font from URL in Node context', function(done) {
load('https://opentype.js.org/fonts/Roboto-Black.ttf', null, { isUrl: true }).then((font) => {
assert.deepEqual(font.names.fontFamily, {en: 'Roboto Black'});
assert.deepEqual(font.names.fontFamily, {en: 'Roboto Black'});
Connum marked this conversation as resolved.
Show resolved Hide resolved
assert.equal(font.unitsPerEm, 2048);
assert.equal(font.glyphs.length, 1294);
const aGlyph = font.charToGlyph('A');
assert.equal(aGlyph.unicode, 65);
assert.equal(aGlyph.path.commands.length, 15);
done();
});
});

it('can load a OpenType/CFF font', function() {
const font = loadSync('./fonts/FiraSansOT-Medium.otf');
assert.deepEqual(font.names.macintosh.fontFamily, {en: 'Fira Sans OT Medium'});
Expand Down