Fix lint errors
This commit is contained in:
parent
a6180830f8
commit
20a348fc0c
107
fonts.js
107
fonts.js
@ -145,7 +145,7 @@ var FontLoader = {
|
|||||||
|
|
||||||
for (var i = 0; i < fonts.length; i++) {
|
for (var i = 0; i < fonts.length; i++) {
|
||||||
var font = fonts[i];
|
var font = fonts[i];
|
||||||
|
|
||||||
// If there is already a fontObj on the font, then it was loaded/attached
|
// If there is already a fontObj on the font, then it was loaded/attached
|
||||||
// to the page already and we don't have to do anything for this font
|
// to the page already and we don't have to do anything for this font
|
||||||
// here future.
|
// here future.
|
||||||
@ -415,111 +415,6 @@ function getUnicodeRangeFor(value) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* FontShape is the minimal shape a FontObject can have to be useful during
|
|
||||||
* executing the IRQueue.
|
|
||||||
*/
|
|
||||||
var FontShape = (function FontShape() {
|
|
||||||
var constructor = function FontShape_constructor(obj) {
|
|
||||||
for (var name in obj) {
|
|
||||||
this[name] = obj[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = this.loadedName;
|
|
||||||
var bold = this.black ? (this.bold ? 'bolder' : 'bold') :
|
|
||||||
(this.bold ? 'bold' : 'normal');
|
|
||||||
|
|
||||||
var italic = this.italic ? 'italic' : 'normal';
|
|
||||||
this.fontFallback = this.serif ? 'serif' : 'sans-serif';
|
|
||||||
|
|
||||||
this.namePart1 = italic + ' ' + bold + ' ';
|
|
||||||
this.namePart2 = 'px "' + name + '", "';
|
|
||||||
|
|
||||||
this.supported = Object.keys(this.encoding).length != 0;
|
|
||||||
|
|
||||||
// Set the loading flag. Gets set to false in FontLoader.bind().
|
|
||||||
this.loading = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
function int16(bytes) {
|
|
||||||
return (bytes[0] << 8) + (bytes[1] & 0xff);
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor.prototype = {
|
|
||||||
getRule: function fonts_getRule(size, fallback) {
|
|
||||||
fallback = fallback || this.fontFallback;
|
|
||||||
return this.namePart1 + size + this.namePart2 + fallback + '"';
|
|
||||||
},
|
|
||||||
|
|
||||||
charsToUnicode: function fonts_chars2Unicode(chars) {
|
|
||||||
var charsCache = this.charsCache;
|
|
||||||
var str;
|
|
||||||
|
|
||||||
// if we translated this string before, just grab it from the cache
|
|
||||||
if (charsCache) {
|
|
||||||
str = charsCache[chars];
|
|
||||||
if (str)
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
// lazily create the translation cache
|
|
||||||
if (!charsCache)
|
|
||||||
charsCache = this.charsCache = Object.create(null);
|
|
||||||
|
|
||||||
// translate the string using the font's encoding
|
|
||||||
var encoding = this.encoding;
|
|
||||||
if (!encoding)
|
|
||||||
return chars;
|
|
||||||
str = '';
|
|
||||||
|
|
||||||
if (this.composite) {
|
|
||||||
// composite fonts have multi-byte strings convert the string from
|
|
||||||
// single-byte to multi-byte
|
|
||||||
// XXX assuming CIDFonts are two-byte - later need to extract the
|
|
||||||
// correct byte encoding according to the PDF spec
|
|
||||||
var length = chars.length - 1; // looping over two bytes at a time so
|
|
||||||
// loop should never end on the last byte
|
|
||||||
for (var i = 0; i < length; i++) {
|
|
||||||
var charcode = int16([chars.charCodeAt(i++), chars.charCodeAt(i)]);
|
|
||||||
var unicode = encoding[charcode];
|
|
||||||
if ('undefined' == typeof(unicode)) {
|
|
||||||
warn('Unencoded charcode ' + charcode);
|
|
||||||
unicode = charcode;
|
|
||||||
} else {
|
|
||||||
unicode = unicode.unicode;
|
|
||||||
}
|
|
||||||
str += String.fromCharCode(unicode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (var i = 0; i < chars.length; ++i) {
|
|
||||||
var charcode = chars.charCodeAt(i);
|
|
||||||
var unicode = encoding[charcode];
|
|
||||||
if ('undefined' == typeof(unicode)) {
|
|
||||||
warn('Unencoded charcode ' + charcode);
|
|
||||||
unicode = charcode;
|
|
||||||
} else {
|
|
||||||
unicode = unicode.unicode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle surrogate pairs
|
|
||||||
if (unicode > 0xFFFF) {
|
|
||||||
str += String.fromCharCode(unicode & 0xFFFF);
|
|
||||||
unicode >>= 16;
|
|
||||||
}
|
|
||||||
str += String.fromCharCode(unicode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enter the translated string into the cache
|
|
||||||
return (charsCache[chars] = str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return constructor;
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 'Font' is the class the outside world should use, it encapsulate all the font
|
* 'Font' is the class the outside world should use, it encapsulate all the font
|
||||||
* decoding logics whatever type it is (assuming the font type is supported).
|
* decoding logics whatever type it is (assuming the font type is supported).
|
||||||
|
73
worker.js
73
worker.js
@ -11,23 +11,23 @@ var WorkerPage = (function() {
|
|||||||
this.workerPDF = workerPDF;
|
this.workerPDF = workerPDF;
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.objs = objs;
|
this.objs = objs;
|
||||||
|
|
||||||
this.ref = page.ref;
|
this.ref = page.ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
get width() {
|
get width() {
|
||||||
return this.page.width;
|
return this.page.width;
|
||||||
},
|
},
|
||||||
|
|
||||||
get height() {
|
get height() {
|
||||||
return this.page.height;
|
return this.page.height;
|
||||||
},
|
},
|
||||||
|
|
||||||
get stats() {
|
get stats() {
|
||||||
return this.page.stats;
|
return this.page.stats;
|
||||||
},
|
},
|
||||||
|
|
||||||
get view() {
|
get view() {
|
||||||
return this.page.view;
|
return this.page.view;
|
||||||
},
|
},
|
||||||
@ -37,40 +37,40 @@ var WorkerPage = (function() {
|
|||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
// TODO: Place the worker magic HERE.
|
// TODO: Place the worker magic HERE.
|
||||||
// this.page.startRendering(ctx, callback, errback);
|
// this.page.startRendering(ctx, callback, errback);
|
||||||
|
|
||||||
this.startRenderingTime = Date.now();
|
this.startRenderingTime = Date.now();
|
||||||
this.workerPDF.startRendering(this)
|
this.workerPDF.startRendering(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
startRenderingFromIRQueue: function(IRQueue, fonts) {
|
startRenderingFromIRQueue: function(IRQueue, fonts) {
|
||||||
var gfx = new CanvasGraphics(this.ctx, this.objs);
|
var gfx = new CanvasGraphics(this.ctx, this.objs);
|
||||||
|
|
||||||
var startTime = Date.now();
|
var startTime = Date.now();
|
||||||
var callback = function(err) {
|
var callback = function(err) {
|
||||||
var pageNum = this.page.pageNumber + 1;
|
var pageNum = this.page.pageNumber + 1;
|
||||||
console.log("page=%d - rendering time: time=%dms",
|
console.log('page=%d - rendering time: time=%dms',
|
||||||
pageNum, Date.now() - startTime);
|
pageNum, Date.now() - startTime);
|
||||||
console.log("page=%d - total time: time=%dms",
|
console.log('page=%d - total time: time=%dms',
|
||||||
pageNum, Date.now() - this.startRenderingTime);
|
pageNum, Date.now() - this.startRenderingTime);
|
||||||
|
|
||||||
this.callback(err);
|
this.callback(err);
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
this.page.startRenderingFromIRQueue(gfx, IRQueue, fonts, callback);
|
this.page.startRenderingFromIRQueue(gfx, IRQueue, fonts, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
getLinks: function() {
|
getLinks: function() {
|
||||||
return this.page.getLinks();
|
return this.page.getLinks();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return constructor;
|
return constructor;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A PDF document and page is build up of many objects. E.g. there are objects
|
* A PDF document and page is build up of many objects. E.g. there are objects
|
||||||
* for fonts, images, rendering code and such. These objects might get processed
|
* for fonts, images, rendering code and such. These objects might get processed
|
||||||
* inside of a worker. The `PDFObjects` implements some basic functions to manage
|
* inside of a worker. The `PDFObjects` implements some basic functions to
|
||||||
* these objects.
|
* manage these objects.
|
||||||
*/
|
*/
|
||||||
var PDFObjects = (function() {
|
var PDFObjects = (function() {
|
||||||
function PDFObjects() {
|
function PDFObjects() {
|
||||||
@ -98,16 +98,16 @@ var PDFObjects = (function() {
|
|||||||
* object needs to be resolved. If it isn't, this function throws.
|
* object needs to be resolved. If it isn't, this function throws.
|
||||||
*
|
*
|
||||||
* If called *with* a callback, the callback is called with the data of the
|
* If called *with* a callback, the callback is called with the data of the
|
||||||
* object once the object is resolved. That means, if you call this
|
* object once the object is resolved. That means, if you call this
|
||||||
* function and the object is already resolved, the callback gets called
|
* function and the object is already resolved, the callback gets called
|
||||||
* right away.
|
* right away.
|
||||||
*/
|
*/
|
||||||
get: function(objId, callback) {
|
get: function(objId, callback) {
|
||||||
// If there is a callback, then the get can be async and the object is
|
// If there is a callback, then the get can be async and the object is
|
||||||
// not required to be resolved right now
|
// not required to be resolved right now
|
||||||
if (callback) {
|
if (callback) {
|
||||||
this.ensureObj(objId).then(callback);
|
this.ensureObj(objId).then(callback);
|
||||||
}
|
}
|
||||||
// If there isn't a callback, the user expects to get the resolved data
|
// If there isn't a callback, the user expects to get the resolved data
|
||||||
// directly.
|
// directly.
|
||||||
else {
|
else {
|
||||||
@ -116,8 +116,8 @@ var PDFObjects = (function() {
|
|||||||
// If there isn't an object yet or the object isn't resolved, then the
|
// If there isn't an object yet or the object isn't resolved, then the
|
||||||
// data isn't ready yet!
|
// data isn't ready yet!
|
||||||
if (!obj || !obj.isResolved) {
|
if (!obj || !obj.isResolved) {
|
||||||
throw "Requesting object that isn't resolved yet " + objId;
|
throw 'Requesting object that isn\'t resolved yet ' + objId;
|
||||||
}
|
}
|
||||||
// Direct access.
|
// Direct access.
|
||||||
else {
|
else {
|
||||||
return obj.data;
|
return obj.data;
|
||||||
@ -130,7 +130,7 @@ var PDFObjects = (function() {
|
|||||||
*/
|
*/
|
||||||
resolve: function(objId, data) {
|
resolve: function(objId, data) {
|
||||||
var objs = this.objs;
|
var objs = this.objs;
|
||||||
|
|
||||||
// In case there is a promise already on this object, just resolve it.
|
// In case there is a promise already on this object, just resolve it.
|
||||||
if (objs[objId]) {
|
if (objs[objId]) {
|
||||||
objs[objId].resolve(data);
|
objs[objId].resolve(data);
|
||||||
@ -169,13 +169,13 @@ var PDFObjects = (function() {
|
|||||||
// a *resolved* promise which shouldn't be the case!
|
// a *resolved* promise which shouldn't be the case!
|
||||||
this.ensureObj(objId).data = data;
|
this.ensureObj(objId).data = data;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
return PDFObjects;
|
return PDFObjects;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Promise" object.
|
* 'Promise' object.
|
||||||
* Each object that is stored in PDFObjects is based on a Promise object that
|
* Each object that is stored in PDFObjects is based on a Promise object that
|
||||||
* contains the status of the object and the data. There migth be situations,
|
* contains the status of the object and the data. There migth be situations,
|
||||||
* where a function want to use the value of an object, but it isn't ready at
|
* where a function want to use the value of an object, but it isn't ready at
|
||||||
@ -201,12 +201,12 @@ var Promise = (function() {
|
|||||||
this._data = data;
|
this._data = data;
|
||||||
this.hasData = true;
|
this.hasData = true;
|
||||||
} else {
|
} else {
|
||||||
this.isResolved = false;
|
this.isResolved = false;
|
||||||
this._data = EMPTY_PROMISE;
|
this._data = EMPTY_PROMISE;
|
||||||
}
|
}
|
||||||
this.callbacks = [];
|
this.callbacks = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.prototype = {
|
Promise.prototype = {
|
||||||
hasData: false,
|
hasData: false,
|
||||||
|
|
||||||
@ -215,7 +215,8 @@ var Promise = (function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this._data !== EMPTY_PROMISE) {
|
if (this._data !== EMPTY_PROMISE) {
|
||||||
throw "Promise " + this.name + ": Cannot set the data of a promise twice";
|
throw 'Promise ' + this.name +
|
||||||
|
': Cannot set the data of a promise twice';
|
||||||
}
|
}
|
||||||
this._data = data;
|
this._data = data;
|
||||||
this.hasData = true;
|
this.hasData = true;
|
||||||
@ -224,10 +225,10 @@ var Promise = (function() {
|
|||||||
this.onDataCallback(data);
|
this.onDataCallback(data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get data() {
|
get data() {
|
||||||
if (this._data === EMPTY_PROMISE) {
|
if (this._data === EMPTY_PROMISE) {
|
||||||
throw "Promise " + this.name + ": Cannot get data that isn't set";
|
throw 'Promise ' + this.name + ': Cannot get data that isn\'t set';
|
||||||
}
|
}
|
||||||
return this._data;
|
return this._data;
|
||||||
},
|
},
|
||||||
@ -239,35 +240,35 @@ var Promise = (function() {
|
|||||||
this.onDataCallback = callback;
|
this.onDataCallback = callback;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
resolve: function(data) {
|
resolve: function(data) {
|
||||||
if (this.isResolved) {
|
if (this.isResolved) {
|
||||||
throw "A Promise can be resolved only once " + this.name;
|
throw 'A Promise can be resolved only once ' + this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isResolved = true;
|
this.isResolved = true;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
var callbacks = this.callbacks;
|
var callbacks = this.callbacks;
|
||||||
|
|
||||||
for (var i = 0; i < callbacks.length; i++) {
|
for (var i = 0; i < callbacks.length; i++) {
|
||||||
callbacks[i].call(null, data);
|
callbacks[i].call(null, data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
then: function(callback) {
|
then: function(callback) {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
throw "Requiring callback" + this.name;
|
throw 'Requiring callback' + this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the promise is already resolved, call the callback directly.
|
// If the promise is already resolved, call the callback directly.
|
||||||
if (this.isResolved) {
|
if (this.isResolved) {
|
||||||
var data = this.data;
|
var data = this.data;
|
||||||
callback.call(null, data);
|
callback.call(null, data);
|
||||||
} else {
|
} else {
|
||||||
this.callbacks.push(callback);
|
this.callbacks.push(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
return Promise;
|
return Promise;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -9,15 +9,15 @@ var console = {
|
|||||||
var args = Array.prototype.slice.call(arguments);
|
var args = Array.prototype.slice.call(arguments);
|
||||||
postMessage({
|
postMessage({
|
||||||
action: 'console_log',
|
action: 'console_log',
|
||||||
data: args
|
data: args
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
error: function error() {
|
error: function error() {
|
||||||
var args = Array.prototype.slice.call(arguments);
|
var args = Array.prototype.slice.call(arguments);
|
||||||
postMessage({
|
postMessage({
|
||||||
action: 'console_error',
|
action: 'console_error',
|
||||||
data: args
|
data: args
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@ function MessageHandler(name, comObj) {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.comObj = comObj;
|
this.comObj = comObj;
|
||||||
var ah = this.actionHandler = {};
|
var ah = this.actionHandler = {};
|
||||||
|
|
||||||
ah["console_log"] = [function(data) {
|
ah['console_log'] = [function(data) {
|
||||||
console.log.apply(console, data);
|
console.log.apply(console, data);
|
||||||
}]
|
}];
|
||||||
ah["console_error"] = [function(data) {
|
ah['console_error'] = [function(data) {
|
||||||
console.error.apply(console, data);
|
console.error.apply(console, data);
|
||||||
}]
|
}];
|
||||||
|
|
||||||
comObj.onmessage = function(event) {
|
comObj.onmessage = function(event) {
|
||||||
var data = event.data;
|
var data = event.data;
|
||||||
if (data.action in ah) {
|
if (data.action in ah) {
|
||||||
@ -39,8 +39,8 @@ MessageHandler.prototype = {
|
|||||||
send: function(actionName, data) {
|
send: function(actionName, data) {
|
||||||
this.comObj.postMessage({
|
this.comObj.postMessage({
|
||||||
action: actionName,
|
action: actionName,
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
@ -15,5 +15,5 @@ importScripts('processor_handler.js');
|
|||||||
// Listen for messages from the main thread.
|
// Listen for messages from the main thread.
|
||||||
var pdfDoc = null;
|
var pdfDoc = null;
|
||||||
|
|
||||||
var handler = new MessageHandler("worker_processor", this);
|
var handler = new MessageHandler('worker_processor', this);
|
||||||
WorkerProcessorHandler.setup(handler);
|
WorkerProcessorHandler.setup(handler);
|
||||||
|
@ -6,20 +6,21 @@
|
|||||||
var WorkerProcessorHandler = {
|
var WorkerProcessorHandler = {
|
||||||
setup: function(handler) {
|
setup: function(handler) {
|
||||||
var pdfDoc = null;
|
var pdfDoc = null;
|
||||||
|
|
||||||
handler.on("doc", function(data) {
|
handler.on('doc', function(data) {
|
||||||
// Create only the model of the PDFDoc, which is enough for
|
// Create only the model of the PDFDoc, which is enough for
|
||||||
// processing the content of the pdf.
|
// processing the content of the pdf.
|
||||||
pdfDoc = new PDFDocModel(new Stream(data));
|
pdfDoc = new PDFDocModel(new Stream(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.on("page_request", function(pageNum) {
|
handler.on('page_request', function(pageNum) {
|
||||||
pageNum = parseInt(pageNum);
|
pageNum = parseInt(pageNum);
|
||||||
|
|
||||||
var page = pdfDoc.getPage(pageNum);
|
var page = pdfDoc.getPage(pageNum);
|
||||||
|
|
||||||
// The following code does quite the same as Page.prototype.startRendering,
|
// The following code does quite the same as
|
||||||
// but stops at one point and sends the result back to the main thread.
|
// Page.prototype.startRendering, but stops at one point and sends the
|
||||||
|
// result back to the main thread.
|
||||||
var gfx = new CanvasGraphics(null);
|
var gfx = new CanvasGraphics(null);
|
||||||
|
|
||||||
var start = Date.now();
|
var start = Date.now();
|
||||||
@ -29,15 +30,16 @@ var WorkerProcessorHandler = {
|
|||||||
// Pre compile the pdf page and fetch the fonts/images.
|
// Pre compile the pdf page and fetch the fonts/images.
|
||||||
var IRQueue = page.getIRQueue(handler, dependency);
|
var IRQueue = page.getIRQueue(handler, dependency);
|
||||||
|
|
||||||
console.log("page=%d - getIRQueue: time=%dms, len=%d", pageNum, Date.now() - start, IRQueue.fnArray.length);
|
console.log('page=%d - getIRQueue: time=%dms, len=%d', pageNum,
|
||||||
|
Date.now() - start, IRQueue.fnArray.length);
|
||||||
|
|
||||||
if (false /* show used commands */) {
|
if (false /* show used commands */) {
|
||||||
var cmdMap = {};
|
var cmdMap = {};
|
||||||
|
|
||||||
var fnArray = IRQueue .fnArray;
|
var fnArray = IRQueue .fnArray;
|
||||||
for (var i = 0; i < fnArray.length; i++) {
|
for (var i = 0; i < fnArray.length; i++) {
|
||||||
var entry = fnArray[i];
|
var entry = fnArray[i];
|
||||||
if (entry == "paintReadyFormXObject") {
|
if (entry == 'paintReadyFormXObject') {
|
||||||
//console.log(preCompilation.argsArray[i]);
|
//console.log(preCompilation.argsArray[i]);
|
||||||
}
|
}
|
||||||
if (cmdMap[entry] == null) {
|
if (cmdMap[entry] == null) {
|
||||||
@ -46,7 +48,7 @@ var WorkerProcessorHandler = {
|
|||||||
cmdMap[entry] += 1;
|
cmdMap[entry] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("cmds", JSON.stringify(cmdMap));
|
console.log('cmds', JSON.stringify(cmdMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter the dependecies for fonts.
|
// Filter the dependecies for fonts.
|
||||||
@ -66,17 +68,17 @@ var WorkerProcessorHandler = {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
handler.send("page", {
|
handler.send('page', {
|
||||||
pageNum: pageNum,
|
pageNum: pageNum,
|
||||||
IRQueue: IRQueue,
|
IRQueue: IRQueue,
|
||||||
depFonts: fonts
|
depFonts: fonts
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
handler.on("font", function(data) {
|
handler.on('font', function(data) {
|
||||||
var objId = data[0];
|
var objId = data[0];
|
||||||
var name = data[1];
|
var name = data[1];
|
||||||
var file = data[2];
|
var file = data[2];
|
||||||
var properties = data[3];
|
var properties = data[3];
|
||||||
|
|
||||||
var font = {
|
var font = {
|
||||||
@ -92,15 +94,15 @@ var WorkerProcessorHandler = {
|
|||||||
|
|
||||||
var fontFile = new Stream(file.bytes, file.start,
|
var fontFile = new Stream(file.bytes, file.start,
|
||||||
file.end - file.start, fontFileDict);
|
file.end - file.start, fontFileDict);
|
||||||
|
|
||||||
// Check if this is a FlateStream. Otherwise just use the created
|
// Check if this is a FlateStream. Otherwise just use the created
|
||||||
// Stream one. This makes complex_ttf_font.pdf work.
|
// Stream one. This makes complex_ttf_font.pdf work.
|
||||||
var cmf = file.bytes[0];
|
var cmf = file.bytes[0];
|
||||||
if ((cmf & 0x0f) == 0x08) {
|
if ((cmf & 0x0f) == 0x08) {
|
||||||
font.file = new FlateStream(fontFile);
|
font.file = new FlateStream(fontFile);
|
||||||
} else {
|
} else {
|
||||||
font.file = fontFile;
|
font.file = fontFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var obj = new Font(font.name, font.file, font.properties);
|
var obj = new Font(font.name, font.file, font.properties);
|
||||||
@ -119,7 +121,7 @@ var WorkerProcessorHandler = {
|
|||||||
// anymore as we sent over the ready str.
|
// anymore as we sent over the ready str.
|
||||||
delete obj.data;
|
delete obj.data;
|
||||||
|
|
||||||
handler.send("font_ready", [objId, obj]);
|
handler.send('font_ready', [objId, obj]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user