Merge branch 'master' of git://github.com/mozilla/pdf.js into text-select
Conflicts: src/canvas.js
This commit is contained in:
commit
5e1d78ef20
@ -6,13 +6,13 @@
|
|||||||
<Description about="urn:mozilla:install-manifest">
|
<Description about="urn:mozilla:install-manifest">
|
||||||
<em:id>uriloader@pdf.js</em:id>
|
<em:id>uriloader@pdf.js</em:id>
|
||||||
<em:name>pdf.js</em:name>
|
<em:name>pdf.js</em:name>
|
||||||
<em:version>0.1</em:version>
|
<em:version>0.1.0</em:version>
|
||||||
<em:iconURL>chrome://pdf.js/skin/logo.png</em:iconURL>
|
<em:iconURL>chrome://pdf.js/skin/logo.png</em:iconURL>
|
||||||
<em:targetApplication>
|
<em:targetApplication>
|
||||||
<Description>
|
<Description>
|
||||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||||
<em:minVersion>6.0</em:minVersion>
|
<em:minVersion>6.0</em:minVersion>
|
||||||
<em:maxVersion>11.0.*</em:maxVersion>
|
<em:maxVersion>11.0a1</em:maxVersion>
|
||||||
</Description>
|
</Description>
|
||||||
</em:targetApplication>
|
</em:targetApplication>
|
||||||
<em:bootstrap>true</em:bootstrap>
|
<em:bootstrap>true</em:bootstrap>
|
||||||
@ -20,5 +20,6 @@
|
|||||||
<em:creator>Vivien Nicolas</em:creator>
|
<em:creator>Vivien Nicolas</em:creator>
|
||||||
<em:description>pdf.js uri loader</em:description>
|
<em:description>pdf.js uri loader</em:description>
|
||||||
<em:homepageURL>https://github.com/mozilla/pdf.js/</em:homepageURL>
|
<em:homepageURL>https://github.com/mozilla/pdf.js/</em:homepageURL>
|
||||||
|
<em:type>2</em:type>
|
||||||
</Description>
|
</Description>
|
||||||
</RDF>
|
</RDF>
|
||||||
|
@ -568,12 +568,12 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
var current = this.current;
|
var current = this.current;
|
||||||
var textHScale = current.textHScale;
|
var textHScale = current.textHScale;
|
||||||
var font = current.font;
|
var fontMatrix = current.font.fontMatrix || IDENTITY_MATRIX;
|
||||||
|
|
||||||
ctx.transform.apply(ctx, current.textMatrix);
|
ctx.transform.apply(ctx, current.textMatrix);
|
||||||
ctx.scale(1, -1);
|
ctx.scale(1, -1);
|
||||||
ctx.translate(current.x, -1 * current.y);
|
ctx.translate(current.x, -1 * current.y);
|
||||||
ctx.transform.apply(ctx, font.fontMatrix || IDENTITY_MATRIX);
|
ctx.transform.apply(ctx, fontMatrix);
|
||||||
ctx.scale(1 / textHScale, 1);
|
ctx.scale(1 / textHScale, 1);
|
||||||
},
|
},
|
||||||
getTextGeometry: function canvasGetTextGeometry() {
|
getTextGeometry: function canvasGetTextGeometry() {
|
||||||
@ -626,6 +626,8 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
var charSpacing = current.charSpacing;
|
var charSpacing = current.charSpacing;
|
||||||
var wordSpacing = current.wordSpacing;
|
var wordSpacing = current.wordSpacing;
|
||||||
var textHScale = current.textHScale;
|
var textHScale = current.textHScale;
|
||||||
|
var fontMatrix = font.fontMatrix || IDENTITY_MATRIX;
|
||||||
|
var textHScale2 = textHScale * fontMatrix[0];
|
||||||
var glyphsLength = glyphs.length;
|
var glyphsLength = glyphs.length;
|
||||||
var textLayer = this.textLayer;
|
var textLayer = this.textLayer;
|
||||||
var text = {str: '', length: 0, canvasWidth: 0, geom: {}};
|
var text = {str: '', length: 0, canvasWidth: 0, geom: {}};
|
||||||
@ -644,7 +646,6 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
ctx.transform.apply(ctx, current.textMatrix);
|
ctx.transform.apply(ctx, current.textMatrix);
|
||||||
ctx.translate(current.x, current.y);
|
ctx.translate(current.x, current.y);
|
||||||
|
|
||||||
var fontMatrix = font.fontMatrix || IDENTITY_MATRIX;
|
|
||||||
ctx.scale(1 / textHScale, 1);
|
ctx.scale(1 / textHScale, 1);
|
||||||
for (var i = 0; i < glyphsLength; ++i) {
|
for (var i = 0; i < glyphsLength; ++i) {
|
||||||
|
|
||||||
@ -662,13 +663,14 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
this.restore();
|
this.restore();
|
||||||
|
|
||||||
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
|
||||||
var charWidth = transformed[0] * fontSize + charSpacing;
|
var width = transformed[0] * fontSize + charSpacing;
|
||||||
ctx.translate(charWidth, 0);
|
|
||||||
current.x += charWidth;
|
|
||||||
|
|
||||||
text.str += glyph.fontChar;
|
ctx.translate(width, 0);
|
||||||
|
current.x += width * textHScale2;
|
||||||
|
|
||||||
|
text.str += glyph.unicode;
|
||||||
text.length++;
|
text.length++;
|
||||||
text.canvasWidth += charWidth;
|
text.canvasWidth += width;
|
||||||
}
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
} else {
|
} else {
|
||||||
@ -689,12 +691,11 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
ctx.fillText(char, width, 0);
|
ctx.fillText(char, width, 0);
|
||||||
width += charWidth;
|
width += charWidth;
|
||||||
|
|
||||||
text.str += char === ' ' ? ' ' : char;
|
text.str += glyph.unicode === ' ' ? ' ' : glyph.unicode;
|
||||||
text.length++;
|
text.length++;
|
||||||
text.canvasWidth += charWidth;
|
text.canvasWidth += charWidth;
|
||||||
}
|
}
|
||||||
|
current.x += width * textHScale2;
|
||||||
current.x += width;
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -707,7 +708,8 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
var current = this.current;
|
var current = this.current;
|
||||||
var fontSize = current.fontSize;
|
var fontSize = current.fontSize;
|
||||||
var textHScale = current.textHScale;
|
var textHScale2 = current.textHScale *
|
||||||
|
(current.font.fontMatrix || IDENTITY_MATRIX)[0];
|
||||||
var arrLength = arr.length;
|
var arrLength = arr.length;
|
||||||
var textLayer = this.textLayer;
|
var textLayer = this.textLayer;
|
||||||
var font = current.font;
|
var font = current.font;
|
||||||
@ -724,7 +726,7 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
for (var i = 0; i < arrLength; ++i) {
|
for (var i = 0; i < arrLength; ++i) {
|
||||||
var e = arr[i];
|
var e = arr[i];
|
||||||
if (isNum(e)) {
|
if (isNum(e)) {
|
||||||
var spacingLength = -e * 0.001 * fontSize * textHScale;
|
var spacingLength = -e * 0.001 * fontSize * textHScale2;
|
||||||
current.x += spacingLength;
|
current.x += spacingLength;
|
||||||
|
|
||||||
if (textSelection) {
|
if (textSelection) {
|
||||||
|
15
src/core.js
15
src/core.js
@ -560,20 +560,9 @@ var PDFDoc = (function pdfDoc() {
|
|||||||
var properties = data[4];
|
var properties = data[4];
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
|
// Rewrap the ArrayBuffer in a stream.
|
||||||
var fontFileDict = new Dict();
|
var fontFileDict = new Dict();
|
||||||
fontFileDict.map = file.dict.map;
|
file = new Stream(file, 0, file.length, fontFileDict);
|
||||||
|
|
||||||
var fontFile = new Stream(file.bytes, file.start,
|
|
||||||
file.end - file.start, fontFileDict);
|
|
||||||
|
|
||||||
// Check if this is a FlateStream. Otherwise just use the created
|
|
||||||
// Stream one. This makes complex_ttf_font.pdf work.
|
|
||||||
var cmf = file.bytes[0];
|
|
||||||
if ((cmf & 0x0f) == 0x08) {
|
|
||||||
file = new FlateStream(fontFile);
|
|
||||||
} else {
|
|
||||||
file = fontFile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now, resolve the font object here direclty. The real font
|
// For now, resolve the font object here direclty. The real font
|
||||||
|
@ -155,6 +155,11 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
font.loadedName = loadedName;
|
font.loadedName = loadedName;
|
||||||
|
|
||||||
var translated = font.translated;
|
var translated = font.translated;
|
||||||
|
// Convert the file to an ArrayBuffer which will be turned back into
|
||||||
|
// a Stream in the main thread.
|
||||||
|
if (translated.file)
|
||||||
|
translated.file = translated.file.getBytes();
|
||||||
|
|
||||||
handler.send('obj', [
|
handler.send('obj', [
|
||||||
loadedName,
|
loadedName,
|
||||||
'Font',
|
'Font',
|
||||||
@ -493,6 +498,8 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
var baseName = encoding.get('BaseEncoding');
|
var baseName = encoding.get('BaseEncoding');
|
||||||
if (baseName)
|
if (baseName)
|
||||||
baseEncoding = Encodings[baseName.name];
|
baseEncoding = Encodings[baseName.name];
|
||||||
|
else
|
||||||
|
hasEncoding = false; // base encoding was not provided
|
||||||
|
|
||||||
// Load the differences between the base and original
|
// Load the differences between the base and original
|
||||||
if (encoding.has('Differences')) {
|
if (encoding.has('Differences')) {
|
||||||
|
@ -764,6 +764,7 @@ var Font = (function Font() {
|
|||||||
this.hasEncoding = properties.hasEncoding;
|
this.hasEncoding = properties.hasEncoding;
|
||||||
|
|
||||||
this.fontMatrix = properties.fontMatrix;
|
this.fontMatrix = properties.fontMatrix;
|
||||||
|
this.widthMultiplier = 1.0;
|
||||||
if (properties.type == 'Type3')
|
if (properties.type == 'Type3')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -826,6 +827,8 @@ var Font = (function Font() {
|
|||||||
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.fontMatrix = properties.fontMatrix;
|
this.fontMatrix = properties.fontMatrix;
|
||||||
|
this.widthMultiplier = !properties.fontMatrix ? 1.0 :
|
||||||
|
1.0 / properties.fontMatrix[0];
|
||||||
this.encoding = properties.baseEncoding;
|
this.encoding = properties.baseEncoding;
|
||||||
this.hasShortCmap = properties.hasShortCmap;
|
this.hasShortCmap = properties.hasShortCmap;
|
||||||
this.loadedName = getUniqueName();
|
this.loadedName = getUniqueName();
|
||||||
@ -2131,10 +2134,12 @@ var Font = (function Font() {
|
|||||||
if (typeof unicodeChars === 'number')
|
if (typeof unicodeChars === 'number')
|
||||||
unicodeChars = String.fromCharCode(unicodeChars);
|
unicodeChars = String.fromCharCode(unicodeChars);
|
||||||
|
|
||||||
|
width = (isNum(width) ? width : this.defaultWidth) * this.widthMultiplier;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fontChar: String.fromCharCode(unicode),
|
fontChar: String.fromCharCode(unicode),
|
||||||
unicode: unicodeChars,
|
unicode: unicodeChars,
|
||||||
width: isNum(width) ? width : this.defaultWidth,
|
width: width,
|
||||||
codeIRQueue: codeIRQueue
|
codeIRQueue: codeIRQueue
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -4287,6 +4287,7 @@ var GlyphsUnicode = {
|
|||||||
zretroflexhook: 0x0290,
|
zretroflexhook: 0x0290,
|
||||||
zstroke: 0x01B6,
|
zstroke: 0x01B6,
|
||||||
zuhiragana: 0x305A,
|
zuhiragana: 0x305A,
|
||||||
zukatakana: 0x30BA
|
zukatakana: 0x30BA,
|
||||||
|
'.notdef': 0x0000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
1
test/pdfs/piperine.pdf.link
Normal file
1
test/pdfs/piperine.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://www.erowid.org/archive/rhodium/chemistry/3base/piperonal.pepper/piperine.pepper/465e03piperine.pdf
|
1
test/pdfs/protectip.pdf.link
Normal file
1
test/pdfs/protectip.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://leahy.senate.gov/imo/media/doc/BillText-PROTECTIPAct.pdf
|
@ -276,5 +276,19 @@
|
|||||||
"link": false,
|
"link": false,
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{ "id": "protectip",
|
||||||
|
"file": "pdfs/protectip.pdf",
|
||||||
|
"md5": "676e7a7b8f96d04825361832b1838a93",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{ "id": "piperine",
|
||||||
|
"file": "pdfs/piperine.pdf",
|
||||||
|
"md5": "603ca43dc5732dbba1579f122958c0c2",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user