From: Vivien Nicolas <21@vingtetun.org> Date: Thu, 21 Jul 2011 16:29:32 +0000 (+0200) Subject: Merge to upstream X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=2197235470de6c5f978fcdfb8a4ca42989b4d096;p=pdf.js.git Merge to upstream --- 2197235470de6c5f978fcdfb8a4ca42989b4d096 diff --cc fonts.js index 5a64a64,f33cab9..76facb5 --- a/fonts.js +++ b/fonts.js @@@ -21,25 -21,11 +21,10 @@@ var kMaxWaitForFontFace = 1000 * http://cgit.freedesktop.org/poppler/poppler/tree/poppler/GfxFont.cc#n65 */ - var Fonts = (function Fonts() { + var FontMeasure = (function FontMeasure() { - var kScalePrecision = 40; - + var kScalePrecision = 50; - var fonts = []; - - if (!isWorker) { - var ctx = document.createElement('canvas').getContext('2d'); - ctx.scale(1 / kScalePrecision, 1); - } - - var fontCount = 0; - - function FontInfo(name, data, properties) { - this.name = name; - this.data = data; - this.properties = properties; - this.id = fontCount++; - this.loading = true; - this.sizes = []; - } + var ctx = document.createElement('canvas').getContext('2d'); + ctx.scale(1 / kScalePrecision, 1); var current; var measureCache; @@@ -372,10 -341,12 +340,11 @@@ function getUnicodeRangeFor(value) * var type1Font = new Font("MyFontName", binaryFile, propertiesObject); * type1Font.bind(); */ -var Font = (function() { +var Font = (function Font() { var constructor = function font_constructor(name, file, properties) { this.name = name; - this.textMatrix = properties.textMatrix || IDENTITY_MATRIX; this.encoding = properties.encoding; + this.sizes = []; // 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. @@@ -410,10 -380,8 +378,9 @@@ break; } this.data = data; + this.textMatrix = properties.textMatrix || IDENTITY_MATRIX; this.type = properties.type; - this.id = Fonts.registerFont(name, data, properties); - this.loadedName = 'pdfFont' + this.id; + this.loadedName = getUniqueName(); this.compositeFont = properties.compositeFont; }; diff --cc pdf.js index 32779f5,1f02d7d..385b4fe --- a/pdf.js +++ b/pdf.js @@@ -4119,10 -4094,8 +4102,10 @@@ var CanvasGraphics = (function() if (this.ctx.$setFont) { this.ctx.$setFont(fontName, size); } else { - Fonts.setActive(fontName, fontObj, size); - this.ctx.font = size + 'px "' + fontName + '"'; + FontMeasure.setActive(fontObj, size); + + size = (size <= kRasterizerMin) ? size * kScalePrecision : size; + this.ctx.font = size + 'px "' + fontName + '"'; } }, setTextRenderingMode: function(mode) {