Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opentype.js

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opentype.js - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

7

bower.json
{
"name": "opentype.js",
"version": "0.3.1",
"version": "0.4.0",
"main": "dist/opentype.js",

@@ -12,6 +12,9 @@ "keywords": [

"ignore": [
".jshintignore",
".jshintrc",
"build",
"g",
"src",
"test"
"test",
"*.html"
],

@@ -18,0 +21,0 @@ "dependencies": {

{
"name": "opentype.js",
"description": "OpenType font parser",
"version": "0.3.1",
"version": "0.4.0",
"author": {

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

@@ -0,1 +1,5 @@

0.4.0 (Nov 10, 2014)
====================
* Add support for font writing.
0.3.0 (Jun 10, 2014)

@@ -14,2 +18,2 @@ ====================

* Initial release.
* Supports reading TrueType CFF fonts.
* Supports reading TrueType CFF fonts.

@@ -191,2 +191,5 @@ // Glyph encoding

break;
case 3:
this.names = [];
break;
}

@@ -193,0 +196,0 @@ }

@@ -15,19 +15,43 @@ // Geometric objects

Path.prototype.moveTo = function (x, y) {
this.commands.push({type: 'M', x: x, y: y});
this.commands.push({
type: 'M',
x: x,
y: y
});
};
Path.prototype.lineTo = function (x, y) {
this.commands.push({type: 'L', x: x, y: y});
this.commands.push({
type: 'L',
x: x,
y: y
});
};
Path.prototype.curveTo = Path.prototype.bezierCurveTo = function (x1, y1, x2, y2, x, y) {
this.commands.push({type: 'C', x1: x1, y1: y1, x2: x2, y2: y2, x: x, y: y});
this.commands.push({
type: 'C',
x1: x1,
y1: y1,
x2: x2,
y2: y2,
x: x,
y: y
});
};
Path.prototype.quadTo = Path.prototype.quadraticCurveTo = function (x1, y1, x, y) {
this.commands.push({type: 'Q', x1: x1, y1: y1, x: x, y: y});
this.commands.push({
type: 'Q',
x1: x1,
y1: y1,
x: x,
y: y
});
};
Path.prototype.close = Path.prototype.closePath = function () {
this.commands.push({type: 'Z'});
this.commands.push({
type: 'Z'
});
};

@@ -72,2 +96,68 @@

// Convert the Path to a string of path data instructions
// See http://www.w3.org/TR/SVG/paths.html#PathData
// Parameters:
// - decimalPlaces: The amount of decimal places for floating-point values (default: 2)
Path.prototype.toPathData = function (decimalPlaces) {
decimalPlaces = decimalPlaces !== undefined ? decimalPlaces : 2;
function floatToString(v) {
if (Math.round(v) === v) {
return '' + Math.round(v);
} else {
return v.toFixed(decimalPlaces);
}
}
function packValues() {
var s = '';
for (var i = 0; i < arguments.length; i += 1) {
var v = arguments[i];
if (v > 0 && i > 0) {
s += ' ';
}
s += floatToString(v);
}
return s;
}
var d = '';
for (var i = 0; i < this.commands.length; i += 1) {
var cmd = this.commands[i];
if (cmd.type === 'M') {
d += 'M' + packValues(cmd.x, cmd.y);
} else if (cmd.type === 'L') {
d += 'L' + packValues(cmd.x, cmd.y);
} else if (cmd.type === 'C') {
d += 'C' + packValues(cmd.x1, cmd.y1, cmd.x2, cmd.y2, cmd.x, cmd.y);
} else if (cmd.type === 'Q') {
d += 'Q' + packValues(cmd.x1, cmd.y1, cmd.x, cmd.y);
} else if (cmd.type === 'Z') {
d += 'Z';
}
}
return d;
};
// Convert the path to a SVG <path> element, as a string.
// Parameters:
// - decimalPlaces: The amount of decimal places for floating-point values (default: 2)
Path.prototype.toSVG = function (decimalPlaces) {
var svg = '<path d="';
svg += this.toPathData(decimalPlaces);
svg += '"';
if (this.fill & this.fill !== 'black') {
if (this.fill === null) {
svg += ' fill="none"';
} else {
svg += ' fill="' + this.fill + '"';
}
}
if (this.stroke) {
svg += ' stroke="' + this.stroke + '" stroke-width="' + this.strokeWidth + '"';
}
svg += '/>';
return svg;
};
exports.Path = Path;

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

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc