Ensure things work for default fonts like Arial

This commit is contained in:
Julian Viereck 2011-09-08 18:34:54 -07:00
parent a2bf701bfe
commit c370b8a428
3 changed files with 20 additions and 17 deletions

View File

@ -173,7 +173,7 @@ var FontLoader = {
document.documentElement.removeEventListener( document.documentElement.removeEventListener(
'pdfjsFontLoad', checkFontsLoaded, false); 'pdfjsFontLoad', checkFontsLoaded, false);
callback(); callback(objs);
return true; return true;
} }
@ -450,6 +450,8 @@ var Font = (function Font() {
var constructor = function font_constructor(name, file, properties) { var constructor = function font_constructor(name, file, properties) {
this.name = name; this.name = name;
this.encoding = properties.encoding; this.encoding = properties.encoding;
this.glyphs = properties.glyphs;
this.loadedName = properties.loadedName;
this.sizes = []; this.sizes = [];
var names = name.split('+'); var names = name.split('+');
@ -477,7 +479,6 @@ var Font = (function Font() {
// name ArialBlack for example will be replaced by Helvetica. // name ArialBlack for example will be replaced by Helvetica.
this.black = (name.search(/Black/g) != -1); this.black = (name.search(/Black/g) != -1);
this.loadedName = fontName.split('-')[0];
this.loading = false; this.loading = false;
return; return;
} }
@ -514,7 +515,6 @@ var Font = (function Font() {
this.type = properties.type; this.type = properties.type;
this.textMatrix = properties.textMatrix; this.textMatrix = properties.textMatrix;
this.composite = properties.composite; this.composite = properties.composite;
this.loadedName = properties.loadedName;
// TODO: Remove this once we can be sure nothing got broken to du changes // TODO: Remove this once we can be sure nothing got broken to du changes
// in this commit. // in this commit.

4
pdf.js
View File

@ -3427,9 +3427,9 @@ var Page = (function() {
}, },
ensureFonts: function(fonts, callback) { ensureFonts: function(fonts, callback) {
var fontObjs = FontLoader.bind( FontLoader.bind(
fonts, fonts,
function() { function(fontObjs) {
// Rebuild the FontsMap. This is emulating the behavior of the main // Rebuild the FontsMap. This is emulating the behavior of the main
// thread. // thread.
if (fontObjs) { if (fontObjs) {

View File

@ -134,6 +134,8 @@ var WorkerPDFDoc = (function() {
for (var i = 0; i < fonts.length; i++) { for (var i = 0; i < fonts.length; i++) {
var font = fonts[i]; var font = fonts[i];
// Some fonts don't have a file, e.g. the build in ones like Arial.
if (font.file) {
var fontFileDict = new Dict(); var fontFileDict = new Dict();
fontFileDict.map = font.file.dict.map; fontFileDict.map = font.file.dict.map;
@ -149,6 +151,7 @@ var WorkerPDFDoc = (function() {
font.file = fontFile; font.file = fontFile;
} }
} }
}
var images = data.images; var images = data.images;
for (var i = 0; i < images.length; i++) { for (var i = 0; i < images.length; i++) {