From c7aec8ac8ab7e20b6a01d03baaaef29ce19139d4 Mon Sep 17 00:00:00 2001 From: sbarman Date: Wed, 20 Jul 2011 12:57:47 -0700 Subject: [PATCH] used width info in fontDict --- fonts.js | 12 ++++++++++++ pdf.js | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/fonts.js b/fonts.js index e241bb2f9..7ca0daa30 100755 --- a/fonts.js +++ b/fonts.js @@ -399,6 +399,18 @@ var Font = (function() { var cff = new CFF(name, file, properties); } + var widths = properties.glyphWidths; + if (widths) { + var charstrings = cff.charstrings; + for (var i = 0, ii = charstrings.length; i < ii; ++i) { + var charstring = charstrings[i]; + var unicode = charstring.unicode; + var width = widths[unicode]; + if (width) + charstring.width = width; + } + } + // Wrap the CFF data inside an OTF font file data = this.convert(name, cff, properties); break; diff --git a/pdf.js b/pdf.js index 5ce22955c..8e30858bf 100644 --- a/pdf.js +++ b/pdf.js @@ -3820,9 +3820,22 @@ var PartialEvaluator = (function() { fileType = fileType.name; } + var widths = fontDict.get('Widths'); + var firstChar = fontDict.get('FirstChar'); + var lastChar = fontDict.get('LastChar'); + if (widths) { + var glyphWidths = []; + for (var i = 0; i < firstChar; ++i) + glyphWidths.push(0); + + for (var i = 0, ii = widths.length; i < ii; ++i) + glyphWidths.push(widths[i]); + } + var properties = { type: subType.name, subtype: fileType, + glyphWidths: glyphWidths, encoding: encodingMap, charset: charset, firstChar: fontDict.get('FirstChar'),