Socket
Socket
Sign inDemoInstall

opentype.js

Package Overview
Dependencies
2
Maintainers
2
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

2

bower.json
{
"name": "opentype.js",
"version": "1.0.0",
"version": "1.0.1",
"main": "dist/opentype.js",

@@ -5,0 +5,0 @@ "keywords": [

{
"name": "opentype.js",
"description": "OpenType font parser",
"version": "1.0.0",
"version": "1.0.1",
"author": {

@@ -6,0 +6,0 @@ "name": "Frederik De Bleser",

@@ -6,4 +6,4 @@

It gives you access to the <strong>letterforms</strong> of text from the browser or Node.js.
See [the project website](https://opentype.js.org/) for a live demo.
It gives you access to the <strong>letterforms</strong> of text from the browser or Node.js.
See [https://opentype.js.org/](https://opentype.js.org/) for a live demo.

@@ -18,4 +18,4 @@ Features

* Support for TrueType font hinting.
* Support arabic text rendering (See #359)
* Very efficient.
* Support arabic text rendering (See issue #364 & PR #359 #361)
* A low memory mode is available as an option (see #329)
* Runs in the browser and Node.js.

@@ -30,4 +30,6 @@

OpenType.js uses ES6-style imports, so debugging it in Node.js requires running `npm run build` first. Use `npm run watch` to automatically rebuild when files change.
var fontkit = require('fontkit');
Note: OpenType.js uses ES6-style imports, so if you want to edit it and debug it in Node.js run `npm run build` first and use `npm run watch` to automatically rebuild when files change.
### Directly

@@ -43,3 +45,3 @@

<script src="https://cdn.jsdelivr.net/npm/opentype.js@latest/dist/opentype.min.js"></script>
### Using Bower (Deprecated [see official post](https://bower.io/blog/2017/how-to-migrate-away-from-bower/))

@@ -64,18 +66,18 @@

```javascript
opentype.load('fonts/Roboto-Black.ttf', function(err, font) {
if (err) {
alert('Font could not be loaded: ' + err);
} else {
// Now let's display it on a canvas with id "canvas"
var ctx = document.getElementById('canvas').getContext('2d');
// Construct a Path object containing the letter shapes of the given text.
// The other parameters are x, y and fontSize.
// Note that y is the position of the baseline.
var path = font.getPath('Hello, World!', 0, 150, 72);
// If you just want to draw the text you can also use font.draw(ctx, text, x, y, fontSize).
path.draw(ctx);
}
});
opentype.load('fonts/Roboto-Black.ttf', function(err, font) {
if (err) {
alert('Font could not be loaded: ' + err);
} else {
// Now let's display it on a canvas with id "canvas"
var ctx = document.getElementById('canvas').getContext('2d');
// Construct a Path object containing the letter shapes of the given text.
// The other parameters are x, y and fontSize.
// Note that y is the position of the baseline.
var path = font.getPath('Hello, World!', 0, 150, 72);
// If you just want to draw the text you can also use font.draw(ctx, text, x, y, fontSize).
path.draw(ctx);
}
});
```

@@ -102,31 +104,31 @@

```javascript
// Create the bézier paths for each of the glyphs.
// Note that the .notdef glyph is required.
var notdefGlyph = new opentype.Glyph({
name: '.notdef',
unicode: 0,
advanceWidth: 650,
path: new opentype.Path()
});
// Create the bézier paths for each of the glyphs.
// Note that the .notdef glyph is required.
var notdefGlyph = new opentype.Glyph({
name: '.notdef',
unicode: 0,
advanceWidth: 650,
path: new opentype.Path()
});
var aPath = new opentype.Path();
aPath.moveTo(100, 0);
aPath.lineTo(100, 700);
// more drawing instructions...
var aGlyph = new opentype.Glyph({
name: 'A',
unicode: 65,
advanceWidth: 650,
path: aPath
});
var aPath = new opentype.Path();
aPath.moveTo(100, 0);
aPath.lineTo(100, 700);
// more drawing instructions...
var aGlyph = new opentype.Glyph({
name: 'A',
unicode: 65,
advanceWidth: 650,
path: aPath
});
var glyphs = [notdefGlyph, aGlyph];
var font = new opentype.Font({
familyName: 'OpenTypeSans',
styleName: 'Medium',
unitsPerEm: 1000,
ascender: 800,
descender: -200,
glyphs: glyphs});
font.download();
var glyphs = [notdefGlyph, aGlyph];
var font = new opentype.Font({
familyName: 'OpenTypeSans',
styleName: 'Medium',
unitsPerEm: 1000,
ascender: 800,
descender: -200,
glyphs: glyphs});
font.download();
```

@@ -133,0 +135,0 @@

@@ -0,1 +1,4 @@

1.0.1 (April 19, 2019)
* Fix error if defaultLangSys is undefined (Issue #378)
1.0.0 (April 17, 2019)

@@ -2,0 +5,0 @@

@@ -219,5 +219,4 @@ /**

const script = scripts[i];
if (script.tag === scriptTag) {
let defaultLangSys = script.script.defaultLangSys;
return defaultLangSys.featureIndexes;
if (script.tag === scriptTag && script.script.defaultLangSys) {
return script.script.defaultLangSys.featureIndexes;
} else {

@@ -224,0 +223,0 @@ let langSysRecords = script.langSysRecords;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc