Browse Source

PDF.js version 1.2.64 - See mozilla/pdf.js@7e8dacf57b194366f45bcb0074725f2a00e32196

master v1.2.64
Pdf Bot 9 years ago
parent
commit
ce9fc8ecb1
  1. 2
      bower.json
  2. 119
      build/pdf.combined.js
  3. 23
      build/pdf.js
  4. 100
      build/pdf.worker.js
  5. 2
      package.json

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.2.61", "version": "1.2.64",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

119
build/pdf.combined.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.2.61'; PDFJS.version = '1.2.64';
PDFJS.build = 'cbce05b'; PDFJS.build = '7e8dacf';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -4822,16 +4822,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var x = 0, i; var x = 0, i;
for (i = 0; i < glyphsLength; ++i) { for (i = 0; i < glyphsLength; ++i) {
var glyph = glyphs[i]; var glyph = glyphs[i];
if (glyph === null) { if (isNum(glyph)) {
// word break
x += fontDirection * wordSpacing;
continue;
} else if (isNum(glyph)) {
x += spacingDir * glyph * fontSize / 1000; x += spacingDir * glyph * fontSize / 1000;
continue; continue;
} }
var restoreNeeded = false; var restoreNeeded = false;
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
var character = glyph.fontChar; var character = glyph.fontChar;
var accent = glyph.accent; var accent = glyph.accent;
var scaledX, scaledY, scaledAccentX, scaledAccentY; var scaledX, scaledY, scaledAccentX, scaledAccentY;
@ -4875,7 +4872,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} }
} }
var charWidth = width * widthAdvanceScale + charSpacing * fontDirection; var charWidth = width * widthAdvanceScale + spacing * fontDirection;
x += charWidth; x += charWidth;
if (restoreNeeded) { if (restoreNeeded) {
@ -4920,18 +4917,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
for (i = 0; i < glyphsLength; ++i) { for (i = 0; i < glyphsLength; ++i) {
glyph = glyphs[i]; glyph = glyphs[i];
if (glyph === null) { if (isNum(glyph)) {
// word break
this.ctx.translate(wordSpacing, 0);
current.x += wordSpacing * textHScale;
continue;
} else if (isNum(glyph)) {
spacingLength = spacingDir * glyph * fontSize / 1000; spacingLength = spacingDir * glyph * fontSize / 1000;
this.ctx.translate(spacingLength, 0); this.ctx.translate(spacingLength, 0);
current.x += spacingLength * textHScale; current.x += spacingLength * textHScale;
continue; continue;
} }
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
var operatorList = font.charProcOperatorList[glyph.operatorListId]; var operatorList = font.charProcOperatorList[glyph.operatorListId];
if (!operatorList) { if (!operatorList) {
warn('Type3 character \"' + glyph.operatorListId + warn('Type3 character \"' + glyph.operatorListId +
@ -4946,7 +4939,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.restore(); this.restore();
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix); var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
width = transformed[0] * fontSize + charSpacing; width = transformed[0] * fontSize + spacing;
ctx.translate(width, 0); ctx.translate(width, 0);
current.x += width * textHScale; current.x += width * textHScale;
@ -17739,9 +17732,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
for (var i = 0, ii = glyphs.length; i < ii; i++) { for (var i = 0, ii = glyphs.length; i < ii; i++) {
var glyph = glyphs[i]; var glyph = glyphs[i];
if (glyph === null) {
continue;
}
buildPath(glyph.fontChar); buildPath(glyph.fontChar);
// If the glyph has an accent we need to build a path for its // If the glyph has an accent we need to build a path for its
@ -18401,10 +18391,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var defaultVMetrics = font.defaultVMetrics; var defaultVMetrics = font.defaultVMetrics;
for (var i = 0; i < glyphs.length; i++) { for (var i = 0; i < glyphs.length; i++) {
var glyph = glyphs[i]; var glyph = glyphs[i];
if (!glyph) { // Previous glyph was a space.
width += textState.wordSpacing * textState.textHScale;
continue;
}
var vMetricX = null; var vMetricX = null;
var vMetricY = null; var vMetricY = null;
var glyphWidth = null; var glyphWidth = null;
@ -18440,11 +18426,14 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// var x = pt[0]; // var x = pt[0];
// var y = pt[1]; // var y = pt[1];
var charSpacing = 0; var charSpacing = textState.charSpacing;
if (textChunk.str.length > 0) { if (glyph.isSpace) {
// Apply char spacing only when there are chars. var wordSpacing = textState.wordSpacing;
// As a result there is only spacing between glyphs. charSpacing += wordSpacing;
charSpacing = textState.charSpacing; if (wordSpacing > 0) {
addFakeSpaces(wordSpacing * 1000 / textState.fontSize,
textChunk.str);
}
} }
var tx = 0; var tx = 0;
@ -18478,6 +18467,22 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return textChunk; return textChunk;
} }
function addFakeSpaces(width, strBuf) {
var spaceWidth = textState.font.spaceWidth;
if (spaceWidth <= 0) {
return;
}
var fakeSpaces = width / spaceWidth;
if (fakeSpaces > MULTI_SPACE_FACTOR) {
fakeSpaces = Math.round(fakeSpaces);
while (fakeSpaces--) {
strBuf.push(' ');
}
} else if (fakeSpaces > SPACE_FACTOR) {
strBuf.push(' ');
}
}
var timeSlotManager = new TimeSlotManager(); var timeSlotManager = new TimeSlotManager();
return new Promise(function next(resolve, reject) { return new Promise(function next(resolve, reject) {
@ -18556,29 +18561,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// In the default coordinate system, a positive adjustment // In the default coordinate system, a positive adjustment
// has the effect of moving the next glyph painted either to // has the effect of moving the next glyph painted either to
// the left or down by the given amount. // the left or down by the given amount.
var val = items[j] * textState.fontSize / 1000; var advance = items[j];
var val = advance * textState.fontSize / 1000;
if (textState.font.vertical) { if (textState.font.vertical) {
offset = val * textState.textMatrix[3]; offset = val *
textState.translateTextMatrix(0, offset); (textState.textHScale * textState.textMatrix[2] +
textState.textMatrix[3]);
textState.translateTextMatrix(0, val);
// Value needs to be added to height to paint down. // Value needs to be added to height to paint down.
textChunk.height += offset; textChunk.height += offset;
} else { } else {
offset = val * textState.textHScale * offset = val * (
textState.textMatrix[0]; textState.textHScale * textState.textMatrix[0] +
textState.translateTextMatrix(offset, 0); textState.textMatrix[1]);
textState.translateTextMatrix(-val, 0);
// Value needs to be subtracted from width to paint left. // Value needs to be subtracted from width to paint left.
textChunk.width -= offset; textChunk.width -= offset;
advance = -advance;
} }
if (items[j] < 0 && textState.font.spaceWidth > 0) { if (advance > 0) {
var fakeSpaces = -items[j] / textState.font.spaceWidth; addFakeSpaces(advance, textChunk.str);
if (fakeSpaces > MULTI_SPACE_FACTOR) {
fakeSpaces = Math.round(fakeSpaces);
while (fakeSpaces--) {
textChunk.str.push(' ');
}
} else if (fakeSpaces > SPACE_FACTOR) {
textChunk.str.push(' ');
}
} }
} }
} }
@ -23259,23 +23261,26 @@ function getFontType(type, subtype) {
} }
var Glyph = (function GlyphClosure() { var Glyph = (function GlyphClosure() {
function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId) { function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId,
isSpace) {
this.fontChar = fontChar; this.fontChar = fontChar;
this.unicode = unicode; this.unicode = unicode;
this.accent = accent; this.accent = accent;
this.width = width; this.width = width;
this.vmetric = vmetric; this.vmetric = vmetric;
this.operatorListId = operatorListId; this.operatorListId = operatorListId;
this.isSpace = isSpace;
} }
Glyph.prototype.matchesForCache = Glyph.prototype.matchesForCache = function(fontChar, unicode, accent, width,
function(fontChar, unicode, accent, width, vmetric, operatorListId) { vmetric, operatorListId, isSpace) {
return this.fontChar === fontChar && return this.fontChar === fontChar &&
this.unicode === unicode && this.unicode === unicode &&
this.accent === accent && this.accent === accent &&
this.width === width && this.width === width &&
this.vmetric === vmetric && this.vmetric === vmetric &&
this.operatorListId === operatorListId; this.operatorListId === operatorListId &&
this.isSpace === isSpace;
}; };
return Glyph; return Glyph;
@ -25790,7 +25795,7 @@ var Font = (function FontClosure() {
return width; return width;
}, },
charToGlyph: function Font_charToGlyph(charcode) { charToGlyph: function Font_charToGlyph(charcode, isSpace) {
var fontCharCode, width, operatorListId; var fontCharCode, width, operatorListId;
var widthCode = charcode; var widthCode = charcode;
@ -25833,9 +25838,9 @@ var Font = (function FontClosure() {
var glyph = this.glyphCache[charcode]; var glyph = this.glyphCache[charcode];
if (!glyph || if (!glyph ||
!glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric,
operatorListId)) { operatorListId, isSpace)) {
glyph = new Glyph(fontChar, unicode, accent, width, vmetric, glyph = new Glyph(fontChar, unicode, accent, width, vmetric,
operatorListId); operatorListId, isSpace);
this.glyphCache[charcode] = glyph; this.glyphCache[charcode] = glyph;
} }
return glyph; return glyph;
@ -25871,22 +25876,16 @@ var Font = (function FontClosure() {
charcode = c.charcode; charcode = c.charcode;
var length = c.length; var length = c.length;
i += length; i += length;
glyph = this.charToGlyph(charcode); // Space is char with code 0x20 and length 1 in multiple-byte codes.
var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
glyph = this.charToGlyph(charcode, isSpace);
glyphs.push(glyph); glyphs.push(glyph);
// placing null after each word break charcode (ASCII SPACE)
// Ignore occurences of 0x20 in multiple-byte codes.
if (length === 1 && chars.charCodeAt(i - 1) === 0x20) {
glyphs.push(null);
}
} }
} else { } else {
for (i = 0, ii = chars.length; i < ii; ++i) { for (i = 0, ii = chars.length; i < ii; ++i) {
charcode = chars.charCodeAt(i); charcode = chars.charCodeAt(i);
glyph = this.charToGlyph(charcode); glyph = this.charToGlyph(charcode, charcode === 0x20);
glyphs.push(glyph); glyphs.push(glyph);
if (charcode === 0x20) {
glyphs.push(null);
}
} }
} }

23
build/pdf.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.2.61'; PDFJS.version = '1.2.64';
PDFJS.build = 'cbce05b'; PDFJS.build = '7e8dacf';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -4875,16 +4875,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var x = 0, i; var x = 0, i;
for (i = 0; i < glyphsLength; ++i) { for (i = 0; i < glyphsLength; ++i) {
var glyph = glyphs[i]; var glyph = glyphs[i];
if (glyph === null) { if (isNum(glyph)) {
// word break
x += fontDirection * wordSpacing;
continue;
} else if (isNum(glyph)) {
x += spacingDir * glyph * fontSize / 1000; x += spacingDir * glyph * fontSize / 1000;
continue; continue;
} }
var restoreNeeded = false; var restoreNeeded = false;
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
var character = glyph.fontChar; var character = glyph.fontChar;
var accent = glyph.accent; var accent = glyph.accent;
var scaledX, scaledY, scaledAccentX, scaledAccentY; var scaledX, scaledY, scaledAccentX, scaledAccentY;
@ -4928,7 +4925,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} }
} }
var charWidth = width * widthAdvanceScale + charSpacing * fontDirection; var charWidth = width * widthAdvanceScale + spacing * fontDirection;
x += charWidth; x += charWidth;
if (restoreNeeded) { if (restoreNeeded) {
@ -4973,18 +4970,14 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
for (i = 0; i < glyphsLength; ++i) { for (i = 0; i < glyphsLength; ++i) {
glyph = glyphs[i]; glyph = glyphs[i];
if (glyph === null) { if (isNum(glyph)) {
// word break
this.ctx.translate(wordSpacing, 0);
current.x += wordSpacing * textHScale;
continue;
} else if (isNum(glyph)) {
spacingLength = spacingDir * glyph * fontSize / 1000; spacingLength = spacingDir * glyph * fontSize / 1000;
this.ctx.translate(spacingLength, 0); this.ctx.translate(spacingLength, 0);
current.x += spacingLength * textHScale; current.x += spacingLength * textHScale;
continue; continue;
} }
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
var operatorList = font.charProcOperatorList[glyph.operatorListId]; var operatorList = font.charProcOperatorList[glyph.operatorListId];
if (!operatorList) { if (!operatorList) {
warn('Type3 character \"' + glyph.operatorListId + warn('Type3 character \"' + glyph.operatorListId +
@ -4999,7 +4992,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.restore(); this.restore();
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix); var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
width = transformed[0] * fontSize + charSpacing; width = transformed[0] * fontSize + spacing;
ctx.translate(width, 0); ctx.translate(width, 0);
current.x += width * textHScale; current.x += width * textHScale;

100
build/pdf.worker.js vendored

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.2.61'; PDFJS.version = '1.2.64';
PDFJS.build = 'cbce05b'; PDFJS.build = '7e8dacf';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -11154,9 +11154,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
for (var i = 0, ii = glyphs.length; i < ii; i++) { for (var i = 0, ii = glyphs.length; i < ii; i++) {
var glyph = glyphs[i]; var glyph = glyphs[i];
if (glyph === null) {
continue;
}
buildPath(glyph.fontChar); buildPath(glyph.fontChar);
// If the glyph has an accent we need to build a path for its // If the glyph has an accent we need to build a path for its
@ -11816,10 +11813,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var defaultVMetrics = font.defaultVMetrics; var defaultVMetrics = font.defaultVMetrics;
for (var i = 0; i < glyphs.length; i++) { for (var i = 0; i < glyphs.length; i++) {
var glyph = glyphs[i]; var glyph = glyphs[i];
if (!glyph) { // Previous glyph was a space.
width += textState.wordSpacing * textState.textHScale;
continue;
}
var vMetricX = null; var vMetricX = null;
var vMetricY = null; var vMetricY = null;
var glyphWidth = null; var glyphWidth = null;
@ -11855,11 +11848,14 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// var x = pt[0]; // var x = pt[0];
// var y = pt[1]; // var y = pt[1];
var charSpacing = 0; var charSpacing = textState.charSpacing;
if (textChunk.str.length > 0) { if (glyph.isSpace) {
// Apply char spacing only when there are chars. var wordSpacing = textState.wordSpacing;
// As a result there is only spacing between glyphs. charSpacing += wordSpacing;
charSpacing = textState.charSpacing; if (wordSpacing > 0) {
addFakeSpaces(wordSpacing * 1000 / textState.fontSize,
textChunk.str);
}
} }
var tx = 0; var tx = 0;
@ -11893,6 +11889,22 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
return textChunk; return textChunk;
} }
function addFakeSpaces(width, strBuf) {
var spaceWidth = textState.font.spaceWidth;
if (spaceWidth <= 0) {
return;
}
var fakeSpaces = width / spaceWidth;
if (fakeSpaces > MULTI_SPACE_FACTOR) {
fakeSpaces = Math.round(fakeSpaces);
while (fakeSpaces--) {
strBuf.push(' ');
}
} else if (fakeSpaces > SPACE_FACTOR) {
strBuf.push(' ');
}
}
var timeSlotManager = new TimeSlotManager(); var timeSlotManager = new TimeSlotManager();
return new Promise(function next(resolve, reject) { return new Promise(function next(resolve, reject) {
@ -11971,29 +11983,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// In the default coordinate system, a positive adjustment // In the default coordinate system, a positive adjustment
// has the effect of moving the next glyph painted either to // has the effect of moving the next glyph painted either to
// the left or down by the given amount. // the left or down by the given amount.
var val = items[j] * textState.fontSize / 1000; var advance = items[j];
var val = advance * textState.fontSize / 1000;
if (textState.font.vertical) { if (textState.font.vertical) {
offset = val * textState.textMatrix[3]; offset = val *
textState.translateTextMatrix(0, offset); (textState.textHScale * textState.textMatrix[2] +
textState.textMatrix[3]);
textState.translateTextMatrix(0, val);
// Value needs to be added to height to paint down. // Value needs to be added to height to paint down.
textChunk.height += offset; textChunk.height += offset;
} else { } else {
offset = val * textState.textHScale * offset = val * (
textState.textMatrix[0]; textState.textHScale * textState.textMatrix[0] +
textState.translateTextMatrix(offset, 0); textState.textMatrix[1]);
textState.translateTextMatrix(-val, 0);
// Value needs to be subtracted from width to paint left. // Value needs to be subtracted from width to paint left.
textChunk.width -= offset; textChunk.width -= offset;
advance = -advance;
} }
if (items[j] < 0 && textState.font.spaceWidth > 0) { if (advance > 0) {
var fakeSpaces = -items[j] / textState.font.spaceWidth; addFakeSpaces(advance, textChunk.str);
if (fakeSpaces > MULTI_SPACE_FACTOR) {
fakeSpaces = Math.round(fakeSpaces);
while (fakeSpaces--) {
textChunk.str.push(' ');
}
} else if (fakeSpaces > SPACE_FACTOR) {
textChunk.str.push(' ');
}
} }
} }
} }
@ -16674,23 +16683,26 @@ function getFontType(type, subtype) {
} }
var Glyph = (function GlyphClosure() { var Glyph = (function GlyphClosure() {
function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId) { function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId,
isSpace) {
this.fontChar = fontChar; this.fontChar = fontChar;
this.unicode = unicode; this.unicode = unicode;
this.accent = accent; this.accent = accent;
this.width = width; this.width = width;
this.vmetric = vmetric; this.vmetric = vmetric;
this.operatorListId = operatorListId; this.operatorListId = operatorListId;
this.isSpace = isSpace;
} }
Glyph.prototype.matchesForCache = Glyph.prototype.matchesForCache = function(fontChar, unicode, accent, width,
function(fontChar, unicode, accent, width, vmetric, operatorListId) { vmetric, operatorListId, isSpace) {
return this.fontChar === fontChar && return this.fontChar === fontChar &&
this.unicode === unicode && this.unicode === unicode &&
this.accent === accent && this.accent === accent &&
this.width === width && this.width === width &&
this.vmetric === vmetric && this.vmetric === vmetric &&
this.operatorListId === operatorListId; this.operatorListId === operatorListId &&
this.isSpace === isSpace;
}; };
return Glyph; return Glyph;
@ -19205,7 +19217,7 @@ var Font = (function FontClosure() {
return width; return width;
}, },
charToGlyph: function Font_charToGlyph(charcode) { charToGlyph: function Font_charToGlyph(charcode, isSpace) {
var fontCharCode, width, operatorListId; var fontCharCode, width, operatorListId;
var widthCode = charcode; var widthCode = charcode;
@ -19248,9 +19260,9 @@ var Font = (function FontClosure() {
var glyph = this.glyphCache[charcode]; var glyph = this.glyphCache[charcode];
if (!glyph || if (!glyph ||
!glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric,
operatorListId)) { operatorListId, isSpace)) {
glyph = new Glyph(fontChar, unicode, accent, width, vmetric, glyph = new Glyph(fontChar, unicode, accent, width, vmetric,
operatorListId); operatorListId, isSpace);
this.glyphCache[charcode] = glyph; this.glyphCache[charcode] = glyph;
} }
return glyph; return glyph;
@ -19286,22 +19298,16 @@ var Font = (function FontClosure() {
charcode = c.charcode; charcode = c.charcode;
var length = c.length; var length = c.length;
i += length; i += length;
glyph = this.charToGlyph(charcode); // Space is char with code 0x20 and length 1 in multiple-byte codes.
var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
glyph = this.charToGlyph(charcode, isSpace);
glyphs.push(glyph); glyphs.push(glyph);
// placing null after each word break charcode (ASCII SPACE)
// Ignore occurences of 0x20 in multiple-byte codes.
if (length === 1 && chars.charCodeAt(i - 1) === 0x20) {
glyphs.push(null);
}
} }
} else { } else {
for (i = 0, ii = chars.length; i < ii; ++i) { for (i = 0, ii = chars.length; i < ii; ++i) {
charcode = chars.charCodeAt(i); charcode = chars.charCodeAt(i);
glyph = this.charToGlyph(charcode); glyph = this.charToGlyph(charcode, charcode === 0x20);
glyphs.push(glyph); glyphs.push(glyph);
if (charcode === 0x20) {
glyphs.push(null);
}
} }
} }

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.2.61", "version": "1.2.64",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [
"Mozilla", "Mozilla",

Loading…
Cancel
Save