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

canvas

Package Overview
Dependencies
Maintainers
6
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canvas - npm Package Compare versions

Comparing version 1.6.5 to 2.0.0-alpha.1

src/backend/Backend.cc

24

History.md

@@ -1,26 +0,6 @@

1.6.5 / 2017-03-18
Unreleased / patch
==================
* Parse font using parse-css-font and units-css (#891)
* Port has_lib.sh to javascript (#872)
1.6.4 / 2017-02-26
==================
* Make sure Canvas#toDataURL is always async if a callback is passed in (#874)
1.6.3 / 2017-02-14
==================
* Fix isnan() and isinf() on Clang (#864)
1.6.2 / 2016-10-30
==================
* Fix deprecation warnings (#835)
1.6.1 / 2016-10-23
==================
* Convert has_lib.sh to sh so it also works on BSD OSes (#820)
1.6.0 / 2016-10-16

@@ -27,0 +7,0 @@ ==================

@@ -14,2 +14,3 @@ 'use strict';

var canvas = require('./bindings')
, Backends = canvas.Backends
, Canvas = canvas.Canvas

@@ -22,3 +23,2 @@ , Image = canvas.Image

, JPEGStream = require('./jpegstream')
, FontFace = canvas.FontFace
, fs = require('fs')

@@ -34,2 +34,4 @@ , packageJson = require("../package.json")

exports.backends = Backends;
/**

@@ -82,25 +84,10 @@ * Library version.

if (FontFace) {
var Font = function Font(name, path, idx) {
this.name = name;
this._faces = {};
/**
* Resolve paths for registerFont
*/
this.addFace(path, 'normal', 'normal', idx);
};
Canvas.registerFont = function(src, fontFace){
return Canvas._registerFont(fs.realpathSync(src), fontFace);
};
Font.prototype.addFace = function(path, weight, style, idx) {
style = style || 'normal';
weight = weight || 'normal';
var face = new FontFace(path, idx || 0);
this._faces[weight + '-' + style] = face;
};
Font.prototype.getFace = function(weightStyle) {
return this._faces[weightStyle] || this._faces['normal-normal'];
};
exports.Font = Font;
}
/**

@@ -107,0 +94,0 @@ * Context2d implementation.

@@ -91,3 +91,3 @@ 'use strict';

unit: size.unit,
family: parsedFont.family[0]
family: parsedFont.family.join(',')
};

@@ -235,15 +235,2 @@

/**
* Register `font` for usage.
*
* @param {Font} font
* @api public
*/
Context2d.prototype.addFont = function(font) {
this._fonts = this._fonts || {};
if (this._fonts[font.name]) return;
this._fonts[font.name] = font;
};
/**
* Set font.

@@ -261,18 +248,8 @@ *

this.lastFontString = val;
var fonts = this._fonts;
if (fonts && fonts[font.family]) {
var fontObj = fonts[font.family];
var type = font.weight + '-' + font.style;
var fontFace = fontObj.getFace(type);
this._setFontFace(fontFace, font.size);
} else {
this._setFont(
font.weight
, font.style
, font.size
, font.unit
, font.family);
}
this._setFont(
font.weight
, font.style
, font.size
, font.unit
, font.family);
}

@@ -279,0 +256,0 @@ }

@@ -13,3 +13,4 @@ 'use strict';

var Stream = require('stream').Stream;
var Readable = require('stream').Readable;
var util = require('util');

@@ -34,4 +35,10 @@ /**

var JPEGStream = module.exports = function JPEGStream(canvas, options, sync) {
var self = this
, method = sync
if (!(this instanceof JPEGStream)) {
throw new TypeError("Class constructors cannot be invoked without 'new'");
}
Readable.call(this);
var self = this;
var method = sync
? 'streamJPEGSync'

@@ -42,15 +49,29 @@ : 'streamJPEG';

this.canvas = canvas;
this.readable = true;
// TODO: implement async
if ('streamJPEG' == method) method = 'streamJPEGSync';
this.method = method;
};
util.inherits(JPEGStream, Readable);
function noop() {}
JPEGStream.prototype._read = function _read() {
// For now we're not controlling the c++ code's data emission, so we only
// call canvas.streamJPEGSync once and let it emit data at will.
this._read = noop;
var self = this;
var method = this.method;
var bufsize = this.options.bufsize;
var quality = this.options.quality;
var progressive = this.options.progressive;
process.nextTick(function(){
canvas[method](options.bufsize, options.quality, options.progressive, function(err, chunk){
self.canvas[method](bufsize, quality, progressive, function(err, chunk){
if (err) {
self.emit('error', err);
self.readable = false;
} else if (chunk) {
self.emit('data', chunk);
self.push(chunk);
} else {
self.emit('end');
self.readable = false;
self.push(null);
}

@@ -60,7 +81,1 @@ });

};
/**
* Inherit from `EventEmitter`.
*/
JPEGStream.prototype.__proto__ = Stream.prototype;

@@ -11,3 +11,4 @@ 'use strict';

var Stream = require('stream').Stream;
var Readable = require('stream').Readable;
var util = require('util');

@@ -32,2 +33,8 @@ /**

var PDFStream = module.exports = function PDFStream(canvas, sync) {
if (!(this instanceof PDFStream)) {
throw new TypeError("Class constructors cannot be invoked without 'new'");
}
Readable.call(this);
var self = this

@@ -39,15 +46,25 @@ , method = sync

this.canvas = canvas;
this.readable = true;
// TODO: implement async
if ('streamPDF' == method) method = 'streamPDFSync';
this.method = method;
};
util.inherits(PDFStream, Readable);
function noop() {}
PDFStream.prototype._read = function _read() {
// For now we're not controlling the c++ code's data emission, so we only
// call canvas.streamPDFSync once and let it emit data at will.
this._read = noop;
var self = this;
process.nextTick(function(){
canvas[method](function(err, chunk, len){
self.canvas[self.method](function(err, chunk, len){
if (err) {
self.emit('error', err);
self.readable = false;
} else if (len) {
self.emit('data', chunk, len);
self.push(chunk);
} else {
self.emit('end');
self.readable = false;
self.push(null);
}

@@ -57,7 +74,1 @@ });

};
/**
* Inherit from `EventEmitter`.
*/
PDFStream.prototype.__proto__ = Stream.prototype;

@@ -13,3 +13,4 @@ 'use strict';

var Stream = require('stream').Stream;
var Readable = require('stream').Readable;
var util = require('util');

@@ -34,4 +35,10 @@ /**

var PNGStream = module.exports = function PNGStream(canvas, sync) {
var self = this
, method = sync
if (!(this instanceof PNGStream)) {
throw new TypeError("Class constructors cannot be invoked without 'new'");
}
Readable.call(this);
var self = this;
var method = sync
? 'streamPNGSync'

@@ -41,15 +48,42 @@ : 'streamPNG';

this.canvas = canvas;
this.readable = true;
// TODO: implement async
if ('streamPNG' == method) method = 'streamPNGSync';
if ('streamPNG' === method) method = 'streamPNGSync';
this.method = method;
};
util.inherits(PNGStream, Readable);
var PNGStream = module.exports = function PNGStream(canvas, sync) {
Readable.call(this);
var self = this;
var method = sync
? 'streamPNGSync'
: 'streamPNG';
this.sync = sync;
this.canvas = canvas;
// TODO: implement async
if ('streamPNG' === method) method = 'streamPNGSync';
this.method = method;
};
util.inherits(PNGStream, Readable);
function noop() {}
PNGStream.prototype._read = function _read() {
// For now we're not controlling the c++ code's data emission, so we only
// call canvas.streamPNGSync once and let it emit data at will.
this._read = noop;
var self = this;
process.nextTick(function(){
canvas[method](function(err, chunk, len){
self.canvas[self.method](function(err, chunk, len){
if (err) {
self.emit('error', err);
self.readable = false;
} else if (len) {
self.emit('data', chunk, len);
self.push(chunk);
} else {
self.emit('end');
self.readable = false;
self.push(null);
}

@@ -59,7 +93,1 @@ });

};
/**
* Inherit from `EventEmitter`.
*/
PNGStream.prototype.__proto__ = Stream.prototype;
{
"name": "canvas",
"description": "Canvas graphics API backed by Cairo",
"version": "1.6.5",
"version": "2.0.0-alpha.1",
"author": "TJ Holowaychuk <tj@learnboost.com>",

@@ -27,3 +27,3 @@ "contributors": [

"pretest": "node-gyp build",
"test": "standard examples/*.js && mocha test/*.test.js",
"test": "standard examples/*.js test/server.js test/public/*.js benchmark/run.js util/has_lib.js && mocha test/*.test.js",
"pretest-server": "node-gyp build",

@@ -38,10 +38,8 @@ "test-server": "node test/server.js"

"devDependencies": {
"body-parser": "^1.13.3",
"express": "^4.13.2",
"pug": "^2.0.0-beta3",
"mocha": "*",
"standard": "^7.1.1"
"express": "^4.14.0",
"mocha": "^3.1.2",
"standard": "^8.5.0"
},
"engines": {
"node": ">=0.8.0"
"node": ">=4"
},

@@ -48,0 +46,0 @@ "main": "./lib/canvas.js",

@@ -1,3 +0,11 @@

node-canvas
===========
# node-canvas
-----
## This is the documentation for the unreleased version 2.0
**For the current version 1.x documentation, see [the v1.x branch](https://github.com/Automattic/node-canvas/tree/v1.x)**
-----
### Canvas graphics API backed by Cairo

@@ -22,4 +30,6 @@ [![Build Status](https://travis-ci.org/Automattic/node-canvas.svg?branch=master)](https://travis-ci.org/Automattic/node-canvas)

Unless previously installed you'll _need_ __Cairo__. For system-specific installation view the [Wiki](https://github.com/Automattic/node-canvas/wiki/_pages).
Unless previously installed you'll _need_ __Cairo__ and __Pango__. For system-specific installation view the [Wiki](https://github.com/Automattic/node-canvas/wiki/_pages).
Currently the minimum version of node required is __4.0.0__
You can quickly install the dependencies by using the command for your OS:

@@ -29,6 +39,6 @@

----- | -----
OS X | `brew install pkg-config cairo libpng jpeg giflib`
OS X | `brew install pkg-config cairo pango libpng jpeg giflib`
Ubuntu | `sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++`
Fedora | `sudo yum install cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel giflib-devel`
Solaris | `pkgin install cairo pkg-config xproto renderproto kbproto xextproto`
Solaris | `pkgin install cairo pango pkg-config xproto renderproto kbproto xextproto`
Windows | [Instructions on our wiki](https://github.com/Automattic/node-canvas/wiki/Installation---Windows)

@@ -187,2 +197,22 @@

### Canvas.registerFont for bundled fonts
It can be useful to use a custom font file if you are distributing code that uses node-canvas and a specific font. Or perhaps you are using it to do automated tests and you want the renderings to be the same across operating systems regardless of what fonts are installed.
To do that, you should use `Canvas.registerFont`.
**You need to call it before the Canvas is created**
```javascript
Canvas.registerFont('comicsans.ttf', {family: 'Comic Sans'});
var canvas = new Canvas(500, 500),
ctx = canvas.getContext('2d');
ctx.font = '12px "Comic Sans"';
ctx.fillText(250, 10, 'Everyone hates this font :(');
```
The second argument is an object with properties that resemble the CSS properties that are specified in `@font-face` rules. You must specify at least `family`. `weight`, and `style` are optional (and default to "normal").
### CanvasRenderingContext2D#patternQuality

@@ -316,12 +346,2 @@

## Versions
Tested with and designed for:
- node 0.4.2
- cairo 1.8.6
For node 0.2.x `node-canvas` <= 0.4.3 may be used,
0.5.0 and above are designed for node 0.4.x only.
## License

@@ -328,0 +348,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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