fix merge conflicts
This commit is contained in:
commit
8f57135513
6932
cidmaps.js
Normal file
6932
cidmaps.js
Normal file
File diff suppressed because it is too large
Load Diff
109
fonts.js
109
fonts.js
@ -434,6 +434,9 @@ var Font = (function Font() {
|
|||||||
if (properties.type == 'Type3')
|
if (properties.type == 'Type3')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Trying to fix encoding using glyph widths and CIDSystemInfo.
|
||||||
|
this.fixWidths(properties);
|
||||||
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
// The file data is not specified. Trying to fix the font name
|
// The file data is not specified. Trying to fix the font name
|
||||||
// to be used with the canvas.font.
|
// to be used with the canvas.font.
|
||||||
@ -448,6 +451,7 @@ var Font = (function Font() {
|
|||||||
|
|
||||||
this.defaultWidth = properties.defaultWidth;
|
this.defaultWidth = properties.defaultWidth;
|
||||||
this.loadedName = fontName.split('-')[0];
|
this.loadedName = fontName.split('-')[0];
|
||||||
|
this.composite = properties.composite;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1213,25 +1217,11 @@ var Font = (function Font() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var encoding = properties.encoding, i;
|
var encoding = properties.encoding, i;
|
||||||
if (!encoding[0]) {
|
for (i in encoding) {
|
||||||
// the font is directly characters to glyphs with no encoding
|
if (encoding.hasOwnProperty(i)) {
|
||||||
// so create an identity encoding
|
var unicode = encoding[i].unicode;
|
||||||
var widths = properties.widths;
|
if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255))
|
||||||
for (i = 0; i < numGlyphs; i++) {
|
encoding[i].unicode = unicode += kCmapGlyphOffset;
|
||||||
var width = widths[i];
|
|
||||||
encoding[i] = {
|
|
||||||
unicode: i <= 0x1f || (i >= 127 && i <= 255) ?
|
|
||||||
i + kCmapGlyphOffset : i,
|
|
||||||
width: isNum(width) ? width : properties.defaultWidth
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (i in encoding) {
|
|
||||||
if (encoding.hasOwnProperty(i)) {
|
|
||||||
var unicode = encoding[i].unicode;
|
|
||||||
if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255))
|
|
||||||
encoding[i].unicode = unicode += kCmapGlyphOffset;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1407,6 +1397,87 @@ var Font = (function Font() {
|
|||||||
return stringToArray(otf.file);
|
return stringToArray(otf.file);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fixWidths: function font_fixWidths(properties) {
|
||||||
|
if (properties.type !== 'CIDFontType0' &&
|
||||||
|
properties.type !== 'CIDFontType2')
|
||||||
|
return;
|
||||||
|
|
||||||
|
var encoding = properties.encoding;
|
||||||
|
if (encoding[0])
|
||||||
|
return;
|
||||||
|
var glyphsWidths = properties.widths;
|
||||||
|
if (!glyphsWidths)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var defaultWidth = properties.defaultWidth;
|
||||||
|
var cidSystemInfo = properties.cidSystemInfo;
|
||||||
|
var cidToUnicode;
|
||||||
|
if (cidSystemInfo) {
|
||||||
|
cidToUnicode = CIDToUnicodeMaps[
|
||||||
|
cidSystemInfo.registry + '-' + cidSystemInfo.ordering];
|
||||||
|
}
|
||||||
|
if (!cidToUnicode) {
|
||||||
|
// the font is directly characters to glyphs with no encoding
|
||||||
|
// so create an identity encoding
|
||||||
|
for (i = 0; i < 0xD800; i++) {
|
||||||
|
var width = glyphsWidths[i];
|
||||||
|
encoding[i] = {
|
||||||
|
unicode: i,
|
||||||
|
width: isNum(width) ? width : defaultWidth
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// skipping surrogates + 256-user defined
|
||||||
|
for (i = 0xE100; i <= 0xFFFF; i++) {
|
||||||
|
var width = glyphsWidths[i];
|
||||||
|
encoding[i] = {
|
||||||
|
unicode: i,
|
||||||
|
width: isNum(width) ? width : defaultWidth
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
encoding[0] = { unicode: 0, width: 0 };
|
||||||
|
var glyph = 1, i, j, k;
|
||||||
|
for (i = 0; i < cidToUnicode.length; ++i) {
|
||||||
|
var unicode = cidToUnicode[i];
|
||||||
|
var width;
|
||||||
|
if (isArray(unicode)) {
|
||||||
|
var length = unicode.length;
|
||||||
|
width = glyphsWidths[glyph];
|
||||||
|
for (j = 0; j < length; j++) {
|
||||||
|
k = unicode[j];
|
||||||
|
encoding[k] = {
|
||||||
|
unicode: k,
|
||||||
|
width: isNum(width) ? width : defaultWidth
|
||||||
|
};
|
||||||
|
}
|
||||||
|
glyph++;
|
||||||
|
} else if (typeof unicode === 'object') {
|
||||||
|
var fillLength = unicode.f;
|
||||||
|
if (fillLength) {
|
||||||
|
k = unicode.c;
|
||||||
|
for (j = 0; j < fillLength; ++j) {
|
||||||
|
width = glyphsWidths[glyph++];
|
||||||
|
encoding[k] = {
|
||||||
|
unicode: k,
|
||||||
|
width: isNum(width) ? width : defaultWidth
|
||||||
|
};
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
glyph += unicode.s;
|
||||||
|
} else if (unicode) {
|
||||||
|
width = glyphsWidths[glyph++];
|
||||||
|
encoding[unicode] = {
|
||||||
|
unicode: unicode,
|
||||||
|
width: isNum(width) ? width : defaultWidth
|
||||||
|
};
|
||||||
|
} else
|
||||||
|
glyph++;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
bindWorker: function font_bindWorker(data) {
|
bindWorker: function font_bindWorker(data) {
|
||||||
postMessage({
|
postMessage({
|
||||||
action: 'font',
|
action: 'font',
|
||||||
|
124
pdf.js
124
pdf.js
@ -4455,72 +4455,70 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
properties) {
|
properties) {
|
||||||
var type = properties.type, encoding;
|
var type = properties.type, encoding;
|
||||||
if (properties.composite) {
|
if (properties.composite) {
|
||||||
if (type == 'CIDFontType2') {
|
var defaultWidth = xref.fetchIfRef(dict.get('DW')) || 1000;
|
||||||
var defaultWidth = xref.fetchIfRef(dict.get('DW')) || 1000;
|
properties.defaultWidth = defaultWidth;
|
||||||
properties.defaultWidth = defaultWidth;
|
|
||||||
|
|
||||||
var glyphsWidths = {};
|
var glyphsWidths = {};
|
||||||
var widths = xref.fetchIfRef(dict.get('W'));
|
var widths = xref.fetchIfRef(dict.get('W'));
|
||||||
if (widths) {
|
if (widths) {
|
||||||
var start = 0, end = 0;
|
var start = 0, end = 0;
|
||||||
for (var i = 0; i < widths.length; i++) {
|
for (var i = 0; i < widths.length; i++) {
|
||||||
var code = widths[i];
|
var code = widths[i];
|
||||||
if (isArray(code)) {
|
if (isArray(code)) {
|
||||||
for (var j = 0; j < code.length; j++)
|
for (var j = 0; j < code.length; j++)
|
||||||
glyphsWidths[start++] = code[j];
|
glyphsWidths[start++] = code[j];
|
||||||
start = 0;
|
start = 0;
|
||||||
} else if (start) {
|
} else if (start) {
|
||||||
var width = widths[++i];
|
var width = widths[++i];
|
||||||
for (var j = start; j <= code; j++)
|
for (var j = start; j <= code; j++)
|
||||||
glyphsWidths[j] = width;
|
glyphsWidths[j] = width;
|
||||||
start = 0;
|
start = 0;
|
||||||
} else {
|
|
||||||
start = code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
properties.widths = glyphsWidths;
|
|
||||||
|
|
||||||
var cidToGidMap = dict.get('CIDToGIDMap');
|
|
||||||
if (!cidToGidMap || !isRef(cidToGidMap)) {
|
|
||||||
return Object.create(GlyphsUnicode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract the encoding from the CIDToGIDMap
|
|
||||||
var glyphsStream = xref.fetchIfRef(cidToGidMap);
|
|
||||||
var glyphsData = glyphsStream.getBytes(0);
|
|
||||||
|
|
||||||
// Glyph ids are big-endian 2-byte values
|
|
||||||
encoding = properties.encoding;
|
|
||||||
|
|
||||||
// Set encoding 0 to later verify the font has an encoding
|
|
||||||
encoding[0] = { unicode: 0, width: 0 };
|
|
||||||
for (var j = 0; j < glyphsData.length; j++) {
|
|
||||||
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
|
|
||||||
if (glyphID == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var code = j >> 1;
|
|
||||||
var width = glyphsWidths[code];
|
|
||||||
encoding[code] = {
|
|
||||||
unicode: glyphID,
|
|
||||||
width: isNum(width) ? width : defaultWidth
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} else if (type == 'CIDFontType0') {
|
|
||||||
if (isName(encoding)) {
|
|
||||||
// Encoding is a predefined CMap
|
|
||||||
if (encoding.name == 'Identity-H') {
|
|
||||||
TODO('Need to create an identity cmap');
|
|
||||||
} else {
|
} else {
|
||||||
TODO('Need to support predefined CMaps see PDF 32000-1:2008 ' +
|
start = code;
|
||||||
'9.7.5.2 Predefined CMaps');
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
TODO('Need to support encoding streams see PDF 32000-1:2008 ' +
|
|
||||||
'9.7.5.3');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
properties.widths = glyphsWidths;
|
||||||
|
|
||||||
|
// Glyph ids are big-endian 2-byte values
|
||||||
|
encoding = properties.encoding;
|
||||||
|
|
||||||
|
// CIDSystemInfo might help to match width and glyphs
|
||||||
|
var cidSystemInfo = dict.get('CIDSystemInfo');
|
||||||
|
if (isDict(cidSystemInfo)) {
|
||||||
|
properties.cidSystemInfo = {
|
||||||
|
registry: cidSystemInfo.get('Registry'),
|
||||||
|
ordering: cidSystemInfo.get('Ordering'),
|
||||||
|
supplement: cidSystemInfo.get('Supplement')
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var cidToGidMap = dict.get('CIDToGIDMap');
|
||||||
|
if (!cidToGidMap || !isRef(cidToGidMap)) {
|
||||||
|
|
||||||
|
|
||||||
|
return Object.create(GlyphsUnicode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the encoding from the CIDToGIDMap
|
||||||
|
var glyphsStream = xref.fetchIfRef(cidToGidMap);
|
||||||
|
var glyphsData = glyphsStream.getBytes(0);
|
||||||
|
|
||||||
|
// Set encoding 0 to later verify the font has an encoding
|
||||||
|
encoding[0] = { unicode: 0, width: 0 };
|
||||||
|
for (var j = 0; j < glyphsData.length; j++) {
|
||||||
|
var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
|
||||||
|
if (glyphID == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var code = j >> 1;
|
||||||
|
var width = glyphsWidths[code];
|
||||||
|
encoding[code] = {
|
||||||
|
unicode: glyphID,
|
||||||
|
width: isNum(width) ? width : defaultWidth
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return Object.create(GlyphsUnicode);
|
return Object.create(GlyphsUnicode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4910,8 +4908,8 @@ var CanvasExtraState = (function canvasExtraState() {
|
|||||||
this.fillColorObj = null;
|
this.fillColorObj = null;
|
||||||
this.strokeColorObj = null;
|
this.strokeColorObj = null;
|
||||||
// Default fore and background colors
|
// Default fore and background colors
|
||||||
this.fillColor = "#000000";
|
this.fillColor = '#000000';
|
||||||
this.strokeColor = "#000000";
|
this.strokeColor = '#000000';
|
||||||
|
|
||||||
this.old = old;
|
this.old = old;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ function nextTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isLastPage(task) {
|
function isLastPage(task) {
|
||||||
return (task.pageNum > task.pdfDoc.numPages);
|
return task.pageNum > task.pdfDoc.numPages || task.pageNum > task.pageLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function canvasToDataURL() {
|
function canvasToDataURL() {
|
||||||
@ -205,7 +205,8 @@ function done() {
|
|||||||
function sendTaskResult(snapshot, task, failure) {
|
function sendTaskResult(snapshot, task, failure) {
|
||||||
var result = { browser: browser,
|
var result = { browser: browser,
|
||||||
id: task.id,
|
id: task.id,
|
||||||
numPages: task.pdfDoc ? task.pdfDoc.numPages : 0,
|
numPages: task.pdfDoc ?
|
||||||
|
(task.pageLimit || task.pdfDoc.numPages) : 0,
|
||||||
failure: failure,
|
failure: failure,
|
||||||
file: task.file,
|
file: task.file,
|
||||||
round: task.round,
|
round: task.round,
|
||||||
|
1
test/pdfs/tcpdf_033.pdf.link
Normal file
1
test/pdfs/tcpdf_033.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://www.tcpdf.org/examples/example_033.pdf
|
16
test/test.py
16
test/test.py
@ -23,6 +23,8 @@ class TestOptions(OptionParser):
|
|||||||
OptionParser.__init__(self, **kwargs)
|
OptionParser.__init__(self, **kwargs)
|
||||||
self.add_option("-m", "--masterMode", action="store_true", dest="masterMode",
|
self.add_option("-m", "--masterMode", action="store_true", dest="masterMode",
|
||||||
help="Run the script in master mode.", default=False)
|
help="Run the script in master mode.", default=False)
|
||||||
|
self.add_option("--noPrompts", action="store_true", dest="noPrompts",
|
||||||
|
help="Uses default answers (intended for CLOUD TESTS only!).", default=False)
|
||||||
self.add_option("--manifestFile", action="store", type="string", dest="manifestFile",
|
self.add_option("--manifestFile", action="store", type="string", dest="manifestFile",
|
||||||
help="A JSON file in the form of test_manifest.json (the default).")
|
help="A JSON file in the form of test_manifest.json (the default).")
|
||||||
self.add_option("-b", "--browser", action="store", type="string", dest="browser",
|
self.add_option("-b", "--browser", action="store", type="string", dest="browser",
|
||||||
@ -321,7 +323,7 @@ def setUp(options):
|
|||||||
if options.masterMode and os.path.isdir(TMPDIR):
|
if options.masterMode and os.path.isdir(TMPDIR):
|
||||||
print 'Temporary snapshot dir tmp/ is still around.'
|
print 'Temporary snapshot dir tmp/ is still around.'
|
||||||
print 'tmp/ can be removed if it has nothing you need.'
|
print 'tmp/ can be removed if it has nothing you need.'
|
||||||
if prompt('SHOULD THIS SCRIPT REMOVE tmp/? THINK CAREFULLY'):
|
if options.noPrompts or prompt('SHOULD THIS SCRIPT REMOVE tmp/? THINK CAREFULLY'):
|
||||||
subprocess.call(( 'rm', '-rf', 'tmp' ))
|
subprocess.call(( 'rm', '-rf', 'tmp' ))
|
||||||
|
|
||||||
assert not os.path.isdir(TMPDIR)
|
assert not os.path.isdir(TMPDIR)
|
||||||
@ -414,8 +416,9 @@ def checkEq(task, results, browser, masterMode):
|
|||||||
|
|
||||||
path = os.path.join(pfx, str(page + 1))
|
path = os.path.join(pfx, str(page + 1))
|
||||||
if not os.access(path, os.R_OK):
|
if not os.access(path, os.R_OK):
|
||||||
print 'WARNING: no reference snapshot', path
|
|
||||||
State.numEqNoSnapshot += 1
|
State.numEqNoSnapshot += 1
|
||||||
|
if not masterMode:
|
||||||
|
print 'WARNING: no reference snapshot', path
|
||||||
else:
|
else:
|
||||||
f = open(path)
|
f = open(path)
|
||||||
ref = f.read()
|
ref = f.read()
|
||||||
@ -444,8 +447,9 @@ def checkEq(task, results, browser, masterMode):
|
|||||||
try:
|
try:
|
||||||
os.makedirs(tmpTaskDir)
|
os.makedirs(tmpTaskDir)
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
print >>sys.stderr, 'Creating', tmpTaskDir, 'failed!'
|
if e.errno != 17: # file exists
|
||||||
|
print >>sys.stderr, 'Creating', tmpTaskDir, 'failed!'
|
||||||
|
|
||||||
of = open(os.path.join(tmpTaskDir, str(page + 1)), 'w')
|
of = open(os.path.join(tmpTaskDir, str(page + 1)), 'w')
|
||||||
of.write(snapshot)
|
of.write(snapshot)
|
||||||
of.close()
|
of.close()
|
||||||
@ -503,10 +507,10 @@ def maybeUpdateRefImages(options, browser):
|
|||||||
print ' Yes! The references in tmp/ can be synced with ref/.'
|
print ' Yes! The references in tmp/ can be synced with ref/.'
|
||||||
if options.reftest:
|
if options.reftest:
|
||||||
startReftest(browser, options)
|
startReftest(browser, options)
|
||||||
if not prompt('Would you like to update the master copy in ref/?'):
|
if options.noPrompts or not prompt('Would you like to update the master copy in ref/?'):
|
||||||
print ' OK, not updating.'
|
print ' OK, not updating.'
|
||||||
else:
|
else:
|
||||||
sys.stdout.write(' Updating ... ')
|
sys.stdout.write(' Updating ref/ ... ')
|
||||||
|
|
||||||
# XXX unclear what to do on errors here ...
|
# XXX unclear what to do on errors here ...
|
||||||
# NB: do *NOT* pass --delete to rsync. That breaks this
|
# NB: do *NOT* pass --delete to rsync. That breaks this
|
||||||
|
@ -171,6 +171,12 @@
|
|||||||
"skipPages": [ 16 ],
|
"skipPages": [ 16 ],
|
||||||
"type": "load"
|
"type": "load"
|
||||||
},
|
},
|
||||||
|
{ "id": "tcpdf_033",
|
||||||
|
"file": "pdfs/tcpdf_033.pdf",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "simpletype3font",
|
{ "id": "simpletype3font",
|
||||||
"file": "pdfs/simpletype3font.pdf",
|
"file": "pdfs/simpletype3font.pdf",
|
||||||
"link": false,
|
"link": false,
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<script type="text/javascript" src="/glyphlist.js"></script>
|
<script type="text/javascript" src="/glyphlist.js"></script>
|
||||||
<script type="text/javascript" src="/metrics.js"></script>
|
<script type="text/javascript" src="/metrics.js"></script>
|
||||||
<script type="text/javascript" src="/charsets.js"></script>
|
<script type="text/javascript" src="/charsets.js"></script>
|
||||||
|
<script type="text/javascript" src="/cidmaps.js"></script>
|
||||||
<script type="text/javascript" src="driver.js"></script>
|
<script type="text/javascript" src="driver.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<script type="text/javascript" src="../glyphlist.js"></script>
|
<script type="text/javascript" src="../glyphlist.js"></script>
|
||||||
<script type="text/javascript" src="../metrics.js"></script>
|
<script type="text/javascript" src="../metrics.js"></script>
|
||||||
<script type="text/javascript" src="../charsets.js"></script>
|
<script type="text/javascript" src="../charsets.js"></script>
|
||||||
|
<script type="text/javascript" src="../cidmaps.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user