Pass the ignoreErrors
API option to the FontFaceObject
constructor, and utilize it in getPathGenerator
to ignore missing glyphs
Obviously it's still not possible to render non-embedded fonts as paths, but in this way the rest of the page will at least be allowed to continue rendering. *Please note:* Including the 14 standard fonts in PDF.js probably wouldn't be *that* difficult to implement. (I'm not a lawyer, but the fonts from PDFium could probably be used given their BSD license.) However, the main blocker ought to be the total size of the necessary font data, since I cannot imagine people being OK with shipping ~5 MB of (additional) font data with Firefox. (Based on the reactions when the CMap files were added, and those are only ~1 MB in size.)
This commit is contained in:
parent
fe288bb872
commit
bf0db0fb72
@ -1884,6 +1884,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
var font = new FontFaceObject(exportedData, {
|
var font = new FontFaceObject(exportedData, {
|
||||||
isEvalSupported: params.isEvalSupported,
|
isEvalSupported: params.isEvalSupported,
|
||||||
disableFontFace: params.disableFontFace,
|
disableFontFace: params.disableFontFace,
|
||||||
|
ignoreErrors: params.ignoreErrors,
|
||||||
fontRegistry,
|
fontRegistry,
|
||||||
});
|
});
|
||||||
var fontReady = (fontObjs) => {
|
var fontReady = (fontObjs) => {
|
||||||
|
@ -338,6 +338,7 @@ var IsEvalSupportedCached = {
|
|||||||
var FontFaceObject = (function FontFaceObjectClosure() {
|
var FontFaceObject = (function FontFaceObjectClosure() {
|
||||||
function FontFaceObject(translatedData, { isEvalSupported = true,
|
function FontFaceObject(translatedData, { isEvalSupported = true,
|
||||||
disableFontFace = false,
|
disableFontFace = false,
|
||||||
|
ignoreErrors = false,
|
||||||
fontRegistry = null, }) {
|
fontRegistry = null, }) {
|
||||||
this.compiledGlyphs = Object.create(null);
|
this.compiledGlyphs = Object.create(null);
|
||||||
// importing translated data
|
// importing translated data
|
||||||
@ -346,6 +347,7 @@ var FontFaceObject = (function FontFaceObjectClosure() {
|
|||||||
}
|
}
|
||||||
this.isEvalSupported = isEvalSupported !== false;
|
this.isEvalSupported = isEvalSupported !== false;
|
||||||
this.disableFontFace = disableFontFace === true;
|
this.disableFontFace = disableFontFace === true;
|
||||||
|
this.ignoreErrors = ignoreErrors === true;
|
||||||
this.fontRegistry = fontRegistry;
|
this.fontRegistry = fontRegistry;
|
||||||
}
|
}
|
||||||
FontFaceObject.prototype = {
|
FontFaceObject.prototype = {
|
||||||
@ -390,7 +392,19 @@ var FontFaceObject = (function FontFaceObjectClosure() {
|
|||||||
return this.compiledGlyphs[character];
|
return this.compiledGlyphs[character];
|
||||||
}
|
}
|
||||||
|
|
||||||
let cmds = objs.get(this.loadedName + '_path_' + character), current;
|
let cmds, current;
|
||||||
|
try {
|
||||||
|
cmds = objs.get(this.loadedName + '_path_' + character);
|
||||||
|
} catch (ex) {
|
||||||
|
if (!this.ignoreErrors) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
warn(`getPathGenerator - ignoring character: "${ex}".`);
|
||||||
|
|
||||||
|
return this.compiledGlyphs[character] = function(c, size) {
|
||||||
|
// No-op function, to allow rendering to continue.
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// If we can, compile cmds into JS for MAXIMUM SPEED...
|
// If we can, compile cmds into JS for MAXIMUM SPEED...
|
||||||
if (this.isEvalSupported && IsEvalSupportedCached.value) {
|
if (this.isEvalSupported && IsEvalSupportedCached.value) {
|
||||||
|
1
test/pdfs/issue4244.pdf.link
Normal file
1
test/pdfs/issue4244.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://web.archive.org/web/20180613082417/https://tcpdf.org/files/examples/example_026.pdf
|
@ -2267,6 +2267,13 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue4244",
|
||||||
|
"file": "pdfs/issue4244.pdf",
|
||||||
|
"md5": "26845274a32a537182ced1fd693a38b2",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "preistabelle",
|
{ "id": "preistabelle",
|
||||||
"file": "pdfs/preistabelle.pdf",
|
"file": "pdfs/preistabelle.pdf",
|
||||||
"md5": "d2f0b2086160d4f3d325c79a5dc1fb4d",
|
"md5": "d2f0b2086160d4f3d325c79a5dc1fb4d",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user