Merge branch 'master' of https://github.com/andreasgal/pdf.js.git into issue-600

This commit is contained in:
notmasteryet 2011-10-08 09:06:49 -05:00
commit b36e8fee5b
4 changed files with 17 additions and 6 deletions

View File

@ -2550,7 +2550,7 @@ var Type2CFF = (function type2CFF() {
var defaultWidth = privateDict['defaultWidthX'];
var charstrings = [];
var differences = properties.differences;
var index = 0;
var index = properties.firstChar || 0;
for (var i = 1; i < charsets.length; i++) {
var code = -1;
var glyph = charsets[i];
@ -2562,7 +2562,8 @@ var Type2CFF = (function type2CFF() {
}
}
var mapping = properties.glyphs[glyph] || {};
var mapping =
properties.glyphs[glyph] || properties.glyphs[index] || {};
if (code == -1)
index = code = mapping.unicode || index;

11
pdf.js
View File

@ -3260,7 +3260,7 @@ var XRef = (function xRefXRef() {
var stream = this.stream;
stream.pos = 0;
var buffer = stream.getBytes();
var position = 0, length = buffer.length;
var position = stream.start, length = buffer.length;
var trailers = [], xrefStms = [];
var state = 0;
var currentToken;
@ -3311,6 +3311,7 @@ var XRef = (function xRefXRef() {
this.readXRef(xrefStms[i]);
}
// finding main trailer
var dict;
for (var i = 0; i < trailers.length; ++i) {
stream.pos = trailers[i];
var parser = new Parser(new Lexer(stream), true);
@ -3318,13 +3319,15 @@ var XRef = (function xRefXRef() {
if (!isCmd(obj, 'trailer'))
continue;
// read the trailer dictionary
var dict;
if (!isDict(dict = parser.getObj()))
continue;
// taking the first one with 'ID'
if (dict.has('ID'))
return dict;
}
// no tailer with 'ID', taking last one (if exists)
if (dict)
return dict;
// nothing helps
error('Invalid PDF structure');
return null;
@ -4595,7 +4598,7 @@ var PartialEvaluator = (function partialEvaluator() {
var glyph = differences[i];
var replaceGlyph = true;
if (!glyph) {
glyph = baseEncoding[i];
glyph = baseEncoding[i] || i;
replaceGlyph = false;
}
var index = GlyphsUnicode[glyph] || i;
@ -4605,7 +4608,7 @@ var PartialEvaluator = (function partialEvaluator() {
width: isNum(width) ? width : properties.defaultWidth
};
if (glyph && (replaceGlyph || !glyphs[glyph]))
if (replaceGlyph || !glyphs[glyph])
glyphs[glyph] = map[i];
// If there is no file, the character mapping can't be modified

View File

@ -0,0 +1 @@
http://www.mit.edu/~6.033/writing-samples/usmanm_dp1.pdf

View File

@ -174,6 +174,12 @@
"rounds": 1,
"type": "load"
},
{ "id": "usmanm-bad",
"file": "pdfs/usmanm-bad.pdf",
"link": true,
"rounds": 1,
"type": "eq"
},
{ "id": "vesta-bad",
"file": "pdfs/vesta.pdf",
"link": true,