fixed up minor bugs
This commit is contained in:
parent
8ac2367fa0
commit
c39eae3ce9
28
fonts.js
28
fonts.js
@ -31,11 +31,13 @@ var Fonts = (function Fonts() {
|
|||||||
ctx.scale(1 / kScalePrecision, 1);
|
ctx.scale(1 / kScalePrecision, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function FontInfo(name, data, properties, id) {
|
var fontCount = 0;
|
||||||
|
|
||||||
|
function FontInfo(name, data, properties) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
this.id = id;
|
this.id = fontCount++;
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.charsCache = Object.create(null);
|
this.charsCache = Object.create(null);
|
||||||
this.sizes = [];
|
this.sizes = [];
|
||||||
@ -45,12 +47,11 @@ var Fonts = (function Fonts() {
|
|||||||
var charsCache;
|
var charsCache;
|
||||||
var measureCache;
|
var measureCache;
|
||||||
|
|
||||||
var fontCount = 0;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
registerFont: function fonts_registerFont(fontName, data, properties) {
|
registerFont: function fonts_registerFont(fontName, data, properties) {
|
||||||
fonts.push(new FontInfo(fontName, data, properties, fontCount));
|
var font = new FontInfo(fontName, data, properties);
|
||||||
return fontCount++;
|
fonts.push(font);
|
||||||
|
return font.id;
|
||||||
},
|
},
|
||||||
blacklistFont: function fonts_blacklistFont(fontName) {
|
blacklistFont: function fonts_blacklistFont(fontName) {
|
||||||
var id = registerFont(fontName, null, {});
|
var id = registerFont(fontName, null, {});
|
||||||
@ -122,8 +123,8 @@ var FontLoader = {
|
|||||||
|
|
||||||
bind: function(fonts, callback) {
|
bind: function(fonts, callback) {
|
||||||
function checkFontsLoaded() {
|
function checkFontsLoaded() {
|
||||||
for (var i = 0; i < fonts.length; i++) {
|
for (var i = 0; i < allIds.length; i++) {
|
||||||
var id = fonts[i].fontDict.fontObj.id;
|
var id = allIds[i];
|
||||||
if (Fonts.lookupById(id).loading) {
|
if (Fonts.lookupById(id).loading) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -136,12 +137,15 @@ var FontLoader = {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var allIds = [];
|
||||||
var rules = [], names = [], ids = [];
|
var rules = [], names = [], ids = [];
|
||||||
|
|
||||||
for (var i = 0; i < fonts.length; i++) {
|
for (var i = 0; i < fonts.length; i++) {
|
||||||
var font = fonts[i];
|
var font = fonts[i];
|
||||||
|
|
||||||
var obj = new Font(font.name, font.file, font.properties);
|
var obj = new Font(font.name, font.file, font.properties);
|
||||||
font.fontDict.fontObj = obj;
|
font.fontDict.fontObj = obj;
|
||||||
|
allIds.push(obj.id);
|
||||||
|
|
||||||
var str = '';
|
var str = '';
|
||||||
var data = Fonts.lookupById(obj.id).data;
|
var data = Fonts.lookupById(obj.id).data;
|
||||||
@ -160,7 +164,7 @@ var FontLoader = {
|
|||||||
if (!isWorker && rules.length) {
|
if (!isWorker && rules.length) {
|
||||||
FontLoader.prepareFontLoadEvent(rules, names, ids);
|
FontLoader.prepareFontLoadEvent(rules, names, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkFontsLoaded()) {
|
if (!checkFontsLoaded()) {
|
||||||
document.documentElement.addEventListener(
|
document.documentElement.addEventListener(
|
||||||
'pdfjsFontLoad', checkFontsLoaded, false);
|
'pdfjsFontLoad', checkFontsLoaded, false);
|
||||||
@ -407,12 +411,6 @@ var Font = (function() {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.encoding = properties.encoding;
|
this.encoding = properties.encoding;
|
||||||
|
|
||||||
// If the font has already been decoded simply return it
|
|
||||||
//if (Fonts.lookup(name)) {
|
|
||||||
// this.font = Fonts.lookup(name).data;
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// If the font is to be ignored, register it like an already loaded font
|
// If the font is to be ignored, register it like an already loaded font
|
||||||
// to avoid the cost of waiting for it be be loaded by the platform.
|
// to avoid the cost of waiting for it be be loaded by the platform.
|
||||||
if (properties.ignore) {
|
if (properties.ignore) {
|
||||||
|
3
pdf.js
3
pdf.js
@ -3687,7 +3687,6 @@ var CanvasGraphics = (function() {
|
|||||||
var font = xref.fetchIfRef(fontRes.get(args[0].name));
|
var font = xref.fetchIfRef(fontRes.get(args[0].name));
|
||||||
assertWellFormed(IsDict(font));
|
assertWellFormed(IsDict(font));
|
||||||
if (!font.translated) {
|
if (!font.translated) {
|
||||||
// sbarman marker
|
|
||||||
font.translated = this.translateFont(font, xref, resources);
|
font.translated = this.translateFont(font, xref, resources);
|
||||||
if (fonts && font.translated) {
|
if (fonts && font.translated) {
|
||||||
// keep track of each font we translated so the caller can
|
// keep track of each font we translated so the caller can
|
||||||
@ -3886,7 +3885,7 @@ var CanvasGraphics = (function() {
|
|||||||
this.ctx.$setFont(fontName, size);
|
this.ctx.$setFont(fontName, size);
|
||||||
} else {
|
} else {
|
||||||
this.ctx.font = size + 'px "' + fontName + '"';
|
this.ctx.font = size + 'px "' + fontName + '"';
|
||||||
Fonts.setActive(font, size);
|
Fonts.setActive(fontObj, size);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setTextRenderingMode: function(mode) {
|
setTextRenderingMode: function(mode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user