Make all fonts render. Use encoding from FontWorker. Render canvas if id!=0 although fonts haven't arrived yet.
Conflicts: worker/pdf.js
This commit is contained in:
parent
c1834c1bb5
commit
23e9064f17
9
fonts.js
9
fonts.js
@ -64,15 +64,8 @@ var Fonts = {
|
|||||||
var unicode = encoding[charcode];
|
var unicode = encoding[charcode];
|
||||||
|
|
||||||
// Check if the glyph has already been converted
|
// Check if the glyph has already been converted
|
||||||
// if (unicode instanceof Name)
|
if (!IsNum(unicode))
|
||||||
try {
|
|
||||||
if (!IsNum(unicode))
|
|
||||||
// if ("name" in unicode)
|
|
||||||
unicode = encoding[unicode] = GlyphsUnicode[unicode.name];
|
unicode = encoding[unicode] = GlyphsUnicode[unicode.name];
|
||||||
|
|
||||||
} catch(e) {
|
|
||||||
console.log("FAIL");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle surrogate pairs
|
// Handle surrogate pairs
|
||||||
if (unicode > 0xFFFF) {
|
if (unicode > 0xFFFF) {
|
||||||
|
@ -37,10 +37,18 @@ function FontWorker() {
|
|||||||
|
|
||||||
FontWorker.prototype = {
|
FontWorker.prototype = {
|
||||||
actionHandler: {
|
actionHandler: {
|
||||||
|
"log": function(data) {
|
||||||
|
console.log.apply(console, data);
|
||||||
|
},
|
||||||
|
|
||||||
"fonts": function(data) {
|
"fonts": function(data) {
|
||||||
// console.log("got processed fonts from worker", Object.keys(data));
|
// console.log("got processed fonts from worker", Object.keys(data));
|
||||||
for (name in data) {
|
for (name in data) {
|
||||||
var base64 = window.btoa(data[name]);
|
// Update the
|
||||||
|
Fonts[name].properties = {
|
||||||
|
encoding: data[name].encoding
|
||||||
|
}
|
||||||
|
var base64 = window.btoa(data[name].str);
|
||||||
|
|
||||||
// Add the @font-face rule to the document
|
// Add the @font-face rule to the document
|
||||||
var url = "url(data:font/opentype;base64," + base64 + ");";
|
var url = "url(data:font/opentype;base64," + base64 + ");";
|
||||||
@ -90,9 +98,12 @@ FontWorker.prototype = {
|
|||||||
// Store only the data on Fonts that is needed later on, such that we
|
// Store only the data on Fonts that is needed later on, such that we
|
||||||
// hold track on as lease memory as possible.
|
// hold track on as lease memory as possible.
|
||||||
Fonts[font.name] = {
|
Fonts[font.name] = {
|
||||||
properties: {
|
// This is set later on the worker replay. For some fonts, the encoding
|
||||||
encoding: font.properties.encoding
|
// is calculated during the conversion process happening on the worker
|
||||||
},
|
// and therefore is not available right now.
|
||||||
|
// properties: {
|
||||||
|
// encoding: font.properties.encoding
|
||||||
|
// },
|
||||||
cache: Object.create(null)
|
cache: Object.create(null)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -348,8 +359,13 @@ function WorkerPDFDoc(canvas) {
|
|||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
if (this.waitingForFonts) {
|
if (this.waitingForFonts) {
|
||||||
console.log("want to render, but not all fonts are there", id);
|
if (id == 0) {
|
||||||
this.waitingForFontsCallback.push(renderData);
|
console.log("want to render, but not all fonts are there", id);
|
||||||
|
this.waitingForFontsCallback.push(renderData);
|
||||||
|
} else {
|
||||||
|
// console.log("assume canvas doesn't have fonts", id);
|
||||||
|
renderData();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
renderData();
|
renderData();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user