add more error checking for font translation
This commit is contained in:
parent
22efbb3af3
commit
050acaf5e0
13
pdf.js
13
pdf.js
@ -1900,8 +1900,10 @@ var CanvasGraphics = (function() {
|
|||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
translateFont: function(fontDict, xref, resources) {
|
translateFont: function(fontDict, xref, resources) {
|
||||||
var descriptor = xref.fetch(fontDict.get("FontDescriptor"));
|
var descriptor = xref.fetch(fontDict.get("FontDescriptor"));
|
||||||
var fontName = descriptor.get("FontName").name;
|
|
||||||
fontName = fontName.replace("+", "_");
|
var fontName = descriptor.get("FontName");
|
||||||
|
assertWellFormed(IsName(fontName), "invalid font name");
|
||||||
|
fontName = fontName.name.replace("+", "_");
|
||||||
|
|
||||||
var fontFile = descriptor.get2("FontFile", "FontFile2");
|
var fontFile = descriptor.get2("FontFile", "FontFile2");
|
||||||
if (!fontFile)
|
if (!fontFile)
|
||||||
@ -1923,17 +1925,16 @@ var CanvasGraphics = (function() {
|
|||||||
|
|
||||||
// Get the font charset if any
|
// Get the font charset if any
|
||||||
var charset = descriptor.get("CharSet");
|
var charset = descriptor.get("CharSet");
|
||||||
if (charset)
|
assertWellFormed(IsString(charset), "invalid charset");
|
||||||
charset = charset.split("/");
|
|
||||||
|
|
||||||
|
charset = charset.split("/");
|
||||||
} else if (IsName(encoding)) {
|
} else if (IsName(encoding)) {
|
||||||
var encoding = Encodings[encoding];
|
var encoding = Encodings[encoding.name];
|
||||||
if (!encoding)
|
if (!encoding)
|
||||||
error("Unknown encoding");
|
error("Unknown encoding");
|
||||||
|
|
||||||
var widths = xref.fetchIfRef(fontDict.get("Widths"));
|
var widths = xref.fetchIfRef(fontDict.get("Widths"));
|
||||||
var firstChar = xref.fetchIfRef(fontDict.get("FirstChar"));
|
var firstChar = xref.fetchIfRef(fontDict.get("FirstChar"));
|
||||||
alert(firstchar);
|
|
||||||
assertWellFormed(IsArray(widths) && IsInteger(firstChar),
|
assertWellFormed(IsArray(widths) && IsInteger(firstChar),
|
||||||
"invalid Widths or FirstChar");
|
"invalid Widths or FirstChar");
|
||||||
var charset = [];
|
var charset = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user