Skip to content

Commit

Permalink
Add more categories of unsupported features.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Dahl committed May 1, 2020
1 parent b6f69d4 commit 5bea7e4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Error(s) in the ExtGState -- sending unsupported feature
// notification and allow parsing/rendering to continue.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.unknown,
featureId: UNSUPPORTED_FEATURES.errorExtGState,
});
warn(`hasBlendModes - ignoring ExtGState: "${ex}".`);
continue;
Expand Down Expand Up @@ -344,7 +344,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Error(s) in the XObject -- sending unsupported feature
// notification and allow parsing/rendering to continue.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.unknown,
featureId: UNSUPPORTED_FEATURES.errorXObject,
});
warn(`hasBlendModes - ignoring XObject: "${ex}".`);
continue;
Expand Down Expand Up @@ -763,7 +763,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Error(s) in the TilingPattern -- sending unsupported feature
// notification and allow rendering to continue.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.unknown,
featureId: UNSUPPORTED_FEATURES.errorTilingPattern,
});
warn(`handleTilingType - ignoring pattern: "${reason}".`);
return;
Expand Down Expand Up @@ -802,7 +802,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Error in the font data -- sending unsupported feature
// notification.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.font,
featureId: UNSUPPORTED_FEATURES.errorFontLoadType3,
});
return new TranslatedFont({
loadedName: "g_font_error",
Expand Down Expand Up @@ -851,7 +851,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Missing setFont operator before text rendering operator -- sending
// unsupported feature notification and allow rendering to continue.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.font,
featureId: UNSUPPORTED_FEATURES.errorFontState,
});
warn(`ensureStateFont: "${reason}".`);
return;
Expand Down Expand Up @@ -995,7 +995,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
// Font not found -- sending unsupported feature notification.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.font,
featureId: UNSUPPORTED_FEATURES.errorFontMissing,
});
warn(`${partialMsg} -- attempting to fallback to a default font.`);

Expand Down Expand Up @@ -1119,7 +1119,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// TODO fontCapability.reject?
// Error in the font data -- sending unsupported feature notification.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.font,
featureId: UNSUPPORTED_FEATURES.errorFontTranslate,
});

try {
Expand Down Expand Up @@ -1194,7 +1194,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Error(s) in the ColorSpace -- sending unsupported feature
// notification and allow rendering to continue.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.unknown,
featureId: UNSUPPORTED_FEATURES.errorColorSpace,
});
warn(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
return null;
Expand Down Expand Up @@ -1382,7 +1382,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Error(s) in the XObject -- sending unsupported feature
// notification and allow rendering to continue.
self.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.unknown,
featureId: UNSUPPORTED_FEATURES.errorXObject,
});
warn(`getOperatorList - ignoring XObject: "${reason}".`);
return;
Expand Down Expand Up @@ -1695,7 +1695,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Error(s) in the OperatorList -- sending unsupported feature
// notification and allow rendering to continue.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.unknown,
featureId: UNSUPPORTED_FEATURES.errorOperatorList,
});
warn(
`getOperatorList - ignoring errors during "${task.name}" ` +
Expand Down Expand Up @@ -2752,7 +2752,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
// Error in the ToUnicode data -- sending unsupported feature
// notification and allow font parsing to continue.
this.handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.font,
featureId: UNSUPPORTED_FEATURES.errorFontToUnicode,
});
warn(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ var WorkerMessageHandler = {
// For compatibility with older behavior, generating unknown
// unsupported feature notification on errors.
handler.send("UnsupportedFeature", {
featureId: UNSUPPORTED_FEATURES.unknown,
featureId: UNSUPPORTED_FEATURES.errorOperatorList,
});

sink.error(reason);
Expand Down
8 changes: 6 additions & 2 deletions src/display/font_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class BaseFontLoader {
try {
await nativeFontFace.loaded;
} catch (ex) {
this._onUnsupportedFeature({ featureId: UNSUPPORTED_FEATURES.font });
this._onUnsupportedFeature({
featureId: UNSUPPORTED_FEATURES.errorFontLoadNative,
});
warn(`Failed to load font '${nativeFontFace.family}': '${ex}'.`);

// When font loading failed, fall back to the built-in font renderer.
Expand Down Expand Up @@ -400,7 +402,9 @@ class FontFaceObject {
throw ex;
}
if (this._onUnsupportedFeature) {
this._onUnsupportedFeature({ featureId: UNSUPPORTED_FEATURES.font });
this._onUnsupportedFeature({
featureId: UNSUPPORTED_FEATURES.errorFontGetPath,
});
}
warn(`getPathGenerator - ignoring character: "${ex}".`);

Expand Down
14 changes: 14 additions & 0 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,26 @@ const OPS = {
};

const UNSUPPORTED_FEATURES = {
/** @deprecated unused */
unknown: "unknown",
forms: "forms",
javaScript: "javaScript",
smask: "smask",
shadingPattern: "shadingPattern",
/** @deprecated unused */
font: "font",
errorTilingPattern: "errorTilingPattern",
errorExtGState: "errorExtGState",
errorXObject: "errorXObject",
errorFontLoadType3: "errorFontLoadType3",
errorFontState: "errorFontState",
errorFontMissing: "errorFontMissing",
errorFontTranslate: "errorFontTranslate",
errorColorSpace: "errorColorSpace",
errorOperatorList: "errorOperatorList",
errorFontToUnicode: "errorFontToUnicode",
errorFontLoadNativeFont: "errorFontLoadNative",
errorFontGetPath: "errorFontGetPath",
};

const PasswordResponses = {
Expand Down

0 comments on commit 5bea7e4

Please sign in to comment.