mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Support (rare) Type3 fonts which contains image resources (issue 10717)
The Type3 font type is not commonly used in PDF documents, as can be seen from telemetry data such as: https://telemetry.mozilla.org/new-pipeline/dist.html#!cumulative=0&end_date=2019-04-09&include_spill=0&keys=__none__!__none__!__none__&max_channel_version=nightly%252F68&measure=PDF_VIEWER_FONT_TYPES&min_channel_version=nightly%252F57&processType=*&product=Firefox&sanitize=1&sort_by_value=0&sort_keys=submissions&start_date=2019-03-18&table=0&trim=1&use_submission_date=0 (see also https://github.com/mozilla/pdf.js/wiki/Enumeration-Assignments-for-the-Telemetry-Histograms#pdf_viewer_font_types). Type3 fonts containing image resources are *very* rare in practice, usually they only contain path rendering operators, but as the issue shows they unfortunately do exist. Currently these Type3-related image resources are not handled in any special way, and given that fonts are document rather than page specific rendering breaks since the image resources are thus not available to the *entire* document. Fortunately fixing this isn't too difficult, but it does require adding a couple of Type3-specific code-paths to the `PartialEvaluator`. In order to keep the implementation simple, particularily on the main-thread, these Type3 image resources are completely decoded on the worker-thread to avoid adding too many special cases. This should not cause any issues, only marginally less efficient code, but given how rare this kind of Type3 font is adding premature optimizations didn't seem at all warranted at this point.
This commit is contained in:
parent
17de90b88a
commit
be604bd195
5 changed files with 60 additions and 18 deletions
|
@ -805,11 +805,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
if (fnId !== OPS.dependency) {
|
||||
this[fnId].apply(this, argsArray[i]);
|
||||
} else {
|
||||
var deps = argsArray[i];
|
||||
for (var n = 0, nn = deps.length; n < nn; n++) {
|
||||
var depObjId = deps[n];
|
||||
var common = depObjId[0] === 'g' && depObjId[1] === '_';
|
||||
var objsPool = common ? commonObjs : objs;
|
||||
for (const depObjId of argsArray[i]) {
|
||||
const objsPool = depObjId.startsWith('g_') ? commonObjs : objs;
|
||||
|
||||
// If the promise isn't resolved yet, add the continueCallback
|
||||
// to the promise and bail out.
|
||||
|
@ -1930,7 +1927,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
},
|
||||
|
||||
paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
|
||||
var domImage = this.objs.get(objId);
|
||||
const domImage = this.processingType3 ? this.commonObjs.get(objId) :
|
||||
this.objs.get(objId);
|
||||
if (!domImage) {
|
||||
warn('Dependent image isn\'t ready yet');
|
||||
return;
|
||||
|
@ -2067,7 +2065,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
},
|
||||
|
||||
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
|
||||
var imgData = this.objs.get(objId);
|
||||
const imgData = this.processingType3 ? this.commonObjs.get(objId) :
|
||||
this.objs.get(objId);
|
||||
if (!imgData) {
|
||||
warn('Dependent image isn\'t ready yet');
|
||||
return;
|
||||
|
@ -2079,7 +2078,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
paintImageXObjectRepeat:
|
||||
function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY,
|
||||
positions) {
|
||||
var imgData = this.objs.get(objId);
|
||||
const imgData = this.processingType3 ? this.commonObjs.get(objId) :
|
||||
this.objs.get(objId);
|
||||
if (!imgData) {
|
||||
warn('Dependent image isn\'t ready yet');
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue