mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 10:15:37 +02:00
more robust fontMatrix parsing, error checking
This commit is contained in:
parent
38d28ecb2e
commit
66eff7a5cb
2 changed files with 19 additions and 1 deletions
|
@ -551,6 +551,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||||
throw 'Can\'t find font for ' + fontRefName;
|
throw 'Can\'t find font for ' + fontRefName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If any of the diagonal elements of a transformation matrix are null
|
||||||
|
// ctx.restore() will fail in FF. See bugzilla bug #719844.
|
||||||
|
if (fontObj.fontMatrix[0] === 0 ||
|
||||||
|
fontObj.fontMatrix[3] === 0 ) {
|
||||||
|
warn('Invalid font matrix for font ' + fontRefName);
|
||||||
|
|
||||||
|
// Fallback
|
||||||
|
fontObj.fontMatrix = IDENTITY_MATRIX;
|
||||||
|
}
|
||||||
|
|
||||||
var name = fontObj.loadedName || 'sans-serif';
|
var name = fontObj.loadedName || 'sans-serif';
|
||||||
|
|
||||||
this.current.font = fontObj;
|
this.current.font = fontObj;
|
||||||
|
|
10
src/fonts.js
10
src/fonts.js
|
@ -2594,7 +2594,15 @@ var Type1Parser = function type1Parser() {
|
||||||
while (str[index++] != ']')
|
while (str[index++] != ']')
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
var array = str.substr(start, count).split(' ');
|
str = str.substr(start, count);
|
||||||
|
|
||||||
|
// Trim
|
||||||
|
str = str.replace(/^\s+/, '');
|
||||||
|
str = str.replace(/\s+$/, '');
|
||||||
|
// Remove adjacent spaces
|
||||||
|
str = str.replace(/\s+/g, ' ');
|
||||||
|
|
||||||
|
var array = str.split(' ');
|
||||||
for (var i = 0, ii = array.length; i < ii; i++)
|
for (var i = 0, ii = array.length; i < ii; i++)
|
||||||
array[i] = parseFloat(array[i] || 0);
|
array[i] = parseFloat(array[i] || 0);
|
||||||
return array;
|
return array;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue