ctx.scale(1 / kScalePrecision, 1);
}
- function FontInfo(name, data, properties, id) {
+ var fontCount = 0;
+
+ function FontInfo(name, data, properties) {
this.name = name;
this.data = data;
this.properties = properties;
- this.id = id;
+ this.id = fontCount++;
this.loading = true;
this.charsCache = Object.create(null);
this.sizes = [];
var charsCache;
var measureCache;
- var fontCount = 0;
-
return {
registerFont: function fonts_registerFont(fontName, data, properties) {
- fonts.push(new FontInfo(fontName, data, properties, fontCount));
- return fontCount++;
+ var font = new FontInfo(fontName, data, properties);
+ fonts.push(font);
+ return font.id;
},
blacklistFont: function fonts_blacklistFont(fontName) {
var id = registerFont(fontName, null, {});
bind: function(fonts, callback) {
function checkFontsLoaded() {
- for (var i = 0; i < fonts.length; i++) {
- var id = fonts[i].fontDict.fontObj.id;
+ for (var i = 0; i < allIds.length; i++) {
+ var id = allIds[i];
if (Fonts.lookupById(id).loading) {
return false;
}
return true;
}
+ var allIds = [];
var rules = [], names = [], ids = [];
+
for (var i = 0; i < fonts.length; i++) {
var font = fonts[i];
var obj = new Font(font.name, font.file, font.properties);
font.fontDict.fontObj = obj;
+ allIds.push(obj.id);
var str = '';
var data = Fonts.lookupById(obj.id).data;
if (!isWorker && rules.length) {
FontLoader.prepareFontLoadEvent(rules, names, ids);
}
-
+
if (!checkFontsLoaded()) {
document.documentElement.addEventListener(
'pdfjsFontLoad', checkFontsLoaded, false);
this.name = name;
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
// to avoid the cost of waiting for it be be loaded by the platform.
if (properties.ignore) {
var font = xref.fetchIfRef(fontRes.get(args[0].name));
assertWellFormed(IsDict(font));
if (!font.translated) {
- // sbarman marker
font.translated = this.translateFont(font, xref, resources);
if (fonts && font.translated) {
// keep track of each font we translated so the caller can
this.ctx.$setFont(fontName, size);
} else {
this.ctx.font = size + 'px "' + fontName + '"';
- Fonts.setActive(font, size);
+ Fonts.setActive(fontObj, size);
}
},
setTextRenderingMode: function(mode) {