From b00df760441b28fceb005c9019755f68b3228311 Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Sun, 26 Jun 2011 20:55:27 +0200 Subject: [PATCH] First pass on FontWorker --- fonts.js | 12 +++- pdf.js | 3 + viewer_worker.html | 3 + worker/canvas.js | 3 +- worker/client.js | 136 +++++++++++++++++++++++++++++++++++++++++++-- worker/console.js | 27 +++++++++ worker/font.js | 65 ++++++++++++++++++++++ worker/pdf.js | 20 +++---- 8 files changed, 247 insertions(+), 22 deletions(-) create mode 100644 worker/console.js create mode 100644 worker/font.js diff --git a/fonts.js b/fonts.js index 728bc5c68..381d37c09 100644 --- a/fonts.js +++ b/fonts.js @@ -64,8 +64,15 @@ var Fonts = { var unicode = encoding[charcode]; // Check if the glyph has already been converted - if (unicode instanceof Name) - unicode = encoding[unicode] = GlyphsUnicode[unicode.name]; + // if (unicode instanceof Name) + try { + if (!IsNum(unicode)) + // if ("name" in unicode) + unicode = encoding[unicode] = GlyphsUnicode[unicode.name]; + + } catch(e) { + console.log("FAIL"); + } // Handle surrogate pairs if (unicode > 0xFFFF) { @@ -165,6 +172,7 @@ var Font = (function () { warn("Font " + properties.type + " is not supported"); break; } + this.data = data; Fonts[name] = { data: data, diff --git a/pdf.js b/pdf.js index 3179f42ec..27ccc6c10 100644 --- a/pdf.js +++ b/pdf.js @@ -3819,6 +3819,9 @@ var CanvasGraphics = (function() { this.current.fontSize = size; this.ctx.font = this.current.fontSize +'px "' + fontName + '", Symbol'; + if (this.ctx.$setFont) { + this.ctx.$setFont(fontName); + } }, setTextRenderingMode: function(mode) { TODO("text rendering mode"); diff --git a/viewer_worker.html b/viewer_worker.html index 6443b22c1..fe3319d62 100644 --- a/viewer_worker.html +++ b/viewer_worker.html @@ -1,6 +1,9 @@ Simple pdf.js page worker viewer + + +