Merge branch 'master' of git://github.com/mozilla/pdf.js into text-select

Conflicts:
	src/canvas.js
This commit is contained in:
Artur Adib 2011-12-01 10:42:07 -05:00
commit 5e1d78ef20
10 changed files with 52 additions and 31 deletions

View File

@ -1,6 +1,6 @@
# pdf.js
## Overview

View File

@ -6,13 +6,13 @@
<Description about="urn:mozilla:install-manifest">
<em:id>uriloader@pdf.js</em:id>
<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:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>6.0</em:minVersion>
<em:maxVersion>11.0.*</em:maxVersion>
<em:maxVersion>11.0a1</em:maxVersion>
</Description>
</em:targetApplication>
<em:bootstrap>true</em:bootstrap>
@ -20,5 +20,6 @@
<em:creator>Vivien Nicolas</em:creator>
<em:description>pdf.js uri loader</em:description>
<em:homepageURL>https://github.com/mozilla/pdf.js/</em:homepageURL>
<em:type>2</em:type>
</Description>
</RDF>

View File

@ -568,12 +568,12 @@ var CanvasGraphics = (function canvasGraphics() {
var ctx = this.ctx;
var current = this.current;
var textHScale = current.textHScale;
var font = current.font;
var fontMatrix = current.font.fontMatrix || IDENTITY_MATRIX;
ctx.transform.apply(ctx, current.textMatrix);
ctx.scale(1, -1);
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);
},
getTextGeometry: function canvasGetTextGeometry() {
@ -626,6 +626,8 @@ var CanvasGraphics = (function canvasGraphics() {
var charSpacing = current.charSpacing;
var wordSpacing = current.wordSpacing;
var textHScale = current.textHScale;
var fontMatrix = font.fontMatrix || IDENTITY_MATRIX;
var textHScale2 = textHScale * fontMatrix[0];
var glyphsLength = glyphs.length;
var textLayer = this.textLayer;
var text = {str: '', length: 0, canvasWidth: 0, geom: {}};
@ -644,7 +646,6 @@ var CanvasGraphics = (function canvasGraphics() {
ctx.transform.apply(ctx, current.textMatrix);
ctx.translate(current.x, current.y);
var fontMatrix = font.fontMatrix || IDENTITY_MATRIX;
ctx.scale(1 / textHScale, 1);
for (var i = 0; i < glyphsLength; ++i) {
@ -662,13 +663,14 @@ var CanvasGraphics = (function canvasGraphics() {
this.restore();
var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
var charWidth = transformed[0] * fontSize + charSpacing;
ctx.translate(charWidth, 0);
current.x += charWidth;
var width = transformed[0] * fontSize + charSpacing;
text.str += glyph.fontChar;
ctx.translate(width, 0);
current.x += width * textHScale2;
text.str += glyph.unicode;
text.length++;
text.canvasWidth += charWidth;
text.canvasWidth += width;
}
ctx.restore();
} else {
@ -689,12 +691,11 @@ var CanvasGraphics = (function canvasGraphics() {
ctx.fillText(char, width, 0);
width += charWidth;
text.str += char === ' ' ? '&nbsp;' : char;
text.str += glyph.unicode === ' ' ? '&nbsp;' : glyph.unicode;
text.length++;
text.canvasWidth += charWidth;
}
current.x += width;
current.x += width * textHScale2;
ctx.restore();
}
@ -707,7 +708,8 @@ var CanvasGraphics = (function canvasGraphics() {
var ctx = this.ctx;
var current = this.current;
var fontSize = current.fontSize;
var textHScale = current.textHScale;
var textHScale2 = current.textHScale *
(current.font.fontMatrix || IDENTITY_MATRIX)[0];
var arrLength = arr.length;
var textLayer = this.textLayer;
var font = current.font;
@ -724,7 +726,7 @@ var CanvasGraphics = (function canvasGraphics() {
for (var i = 0; i < arrLength; ++i) {
var e = arr[i];
if (isNum(e)) {
var spacingLength = -e * 0.001 * fontSize * textHScale;
var spacingLength = -e * 0.001 * fontSize * textHScale2;
current.x += spacingLength;
if (textSelection) {

View File

@ -560,20 +560,9 @@ var PDFDoc = (function pdfDoc() {
var properties = data[4];
if (file) {
// Rewrap the ArrayBuffer in a stream.
var fontFileDict = new Dict();
fontFileDict.map = file.dict.map;
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;
}
file = new Stream(file, 0, file.length, fontFileDict);
}
// For now, resolve the font object here direclty. The real font

View File

@ -155,6 +155,11 @@ var PartialEvaluator = (function partialEvaluator() {
font.loadedName = loadedName;
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', [
loadedName,
'Font',
@ -493,6 +498,8 @@ var PartialEvaluator = (function partialEvaluator() {
var baseName = encoding.get('BaseEncoding');
if (baseName)
baseEncoding = Encodings[baseName.name];
else
hasEncoding = false; // base encoding was not provided
// Load the differences between the base and original
if (encoding.has('Differences')) {

View File

@ -764,6 +764,7 @@ var Font = (function Font() {
this.hasEncoding = properties.hasEncoding;
this.fontMatrix = properties.fontMatrix;
this.widthMultiplier = 1.0;
if (properties.type == 'Type3')
return;
@ -826,6 +827,8 @@ var Font = (function Font() {
this.data = data;
this.fontMatrix = properties.fontMatrix;
this.widthMultiplier = !properties.fontMatrix ? 1.0 :
1.0 / properties.fontMatrix[0];
this.encoding = properties.baseEncoding;
this.hasShortCmap = properties.hasShortCmap;
this.loadedName = getUniqueName();
@ -2131,10 +2134,12 @@ var Font = (function Font() {
if (typeof unicodeChars === 'number')
unicodeChars = String.fromCharCode(unicodeChars);
width = (isNum(width) ? width : this.defaultWidth) * this.widthMultiplier;
return {
fontChar: String.fromCharCode(unicode),
unicode: unicodeChars,
width: isNum(width) ? width : this.defaultWidth,
width: width,
codeIRQueue: codeIRQueue
};
},

View File

@ -4287,6 +4287,7 @@ var GlyphsUnicode = {
zretroflexhook: 0x0290,
zstroke: 0x01B6,
zuhiragana: 0x305A,
zukatakana: 0x30BA
zukatakana: 0x30BA,
'.notdef': 0x0000
};

View File

@ -0,0 +1 @@
http://www.erowid.org/archive/rhodium/chemistry/3base/piperonal.pepper/piperine.pepper/465e03piperine.pdf

View File

@ -0,0 +1 @@
http://leahy.senate.gov/imo/media/doc/BillText-PROTECTIPAct.pdf

View File

@ -276,5 +276,19 @@
"link": false,
"rounds": 1,
"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"
}
]