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

pdfkit

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdfkit - npm Package Compare versions

Comparing version 0.8.1 to 0.8.2

70

js/font/embedded.js

@@ -30,7 +30,65 @@ // Generated by CoffeeScript 1.12.1

this.bbox = this.font.bbox;
this.layoutCache = Object.create(null);
}
EmbeddedFont.prototype.layoutRun = function(text, features) {
var i, j, key, len, position, ref, run;
run = this.font.layout(text, features);
ref = run.positions;
for (i = j = 0, len = ref.length; j < len; i = ++j) {
position = ref[i];
for (key in position) {
position[key] *= this.scale;
}
position.advanceWidth = run.glyphs[i].advanceWidth * this.scale;
}
return run;
};
EmbeddedFont.prototype.layoutCached = function(text) {
var cached, run;
if (cached = this.layoutCache[text]) {
return cached;
}
run = this.layoutRun(text);
this.layoutCache[text] = run;
return run;
};
EmbeddedFont.prototype.layout = function(text, features, onlyWidth) {
var advanceWidth, glyphs, index, last, positions, ref, run;
if (onlyWidth == null) {
onlyWidth = false;
}
if (features) {
return this.layoutRun(text, features);
}
glyphs = onlyWidth ? null : [];
positions = onlyWidth ? null : [];
advanceWidth = 0;
last = 0;
index = 0;
while (index <= text.length) {
if ((index === text.length && last < index) || ((ref = text.charAt(index)) === ' ' || ref === '\t')) {
run = this.layoutCached(text.slice(last, ++index));
if (!onlyWidth) {
glyphs.push.apply(glyphs, run.glyphs);
positions.push.apply(positions, run.positions);
}
advanceWidth += run.advanceWidth;
last = index;
} else {
index++;
}
}
return {
glyphs: glyphs,
positions: positions,
advanceWidth: advanceWidth
};
};
EmbeddedFont.prototype.encode = function(text, features) {
var base, base1, gid, glyph, glyphs, i, j, key, len, positions, ref, res;
ref = this.font.layout(text, features), glyphs = ref.glyphs, positions = ref.positions;
var base, base1, gid, glyph, glyphs, i, j, len, positions, ref, res;
ref = this.layout(text, features), glyphs = ref.glyphs, positions = ref.positions;
res = [];

@@ -47,6 +105,2 @@ for (i = j = 0, len = glyphs.length; j < len; i = ++j) {

}
for (key in positions[i]) {
positions[i][key] *= this.scale;
}
positions[i].advanceWidth = glyph.advanceWidth * this.scale;
}

@@ -58,4 +112,4 @@ return [res, positions];

var scale, width;
width = this.font.layout(string, features).advanceWidth;
scale = size / this.font.unitsPerEm;
width = this.layout(string, features, true).advanceWidth;
scale = size / 1000;
return width * scale;

@@ -62,0 +116,0 @@ };

2

package.json

@@ -12,3 +12,3 @@ {

],
"version": "0.8.1",
"version": "0.8.2",
"homepage": "http://pdfkit.org/",

@@ -15,0 +15,0 @@ "author": {

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