From 10a0a60f8e7ae231a44a91a7b1df9ab1ff166be8 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Fri, 27 Jan 2012 18:53:05 -0600 Subject: [PATCH] Fixing symbols encoding --- src/evaluator.js | 9 ++++++--- src/fonts.js | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/evaluator.js b/src/evaluator.js index 21530f42f..c70013d25 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -481,8 +481,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { properties.cidToGidMap = this.readCidToGidMap(cidToGidMap); } + var flags = properties.flags; var differences = []; - var baseEncoding = Encodings.StandardEncoding; + var baseEncoding = !!(flags & FontFlags.Symbolic) ? + Encodings.symbolsEncoding : Encodings.StandardEncoding; var hasEncoding = dict.has('Encoding'); if (hasEncoding) { var encoding = xref.fetchIfRef(dict.get('Encoding')); @@ -761,8 +763,9 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { // Simulating descriptor flags attribute var fontNameWoStyle = baseFontName.split('-')[0]; var flags = (serifFonts[fontNameWoStyle] || - (fontNameWoStyle.search(/serif/gi) != -1) ? 2 : 0) | - (symbolsFonts[fontNameWoStyle] ? 4 : 32); + (fontNameWoStyle.search(/serif/gi) != -1) ? FontFlags.Serif : 0) | + (symbolsFonts[fontNameWoStyle] ? FontFlags.Symbolic : + FontFlags.Nonsymbolic); var properties = { type: type.name, diff --git a/src/fonts.js b/src/fonts.js index 7f72c8086..bb91d7969 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -19,6 +19,18 @@ var kPDFGlyphSpaceUnits = 1000; // Until hinting is fully supported this constant can be used var kHintingEnabled = false; +var FontFlags = { + FixedPitch: 1, + Serif: 2, + Symbolic: 4, + Script: 8, + Nonsymbolic: 32, + Italic: 64, + AllCap: 65536, + SmallCap: 131072, + ForceBold: 262144 +}; + var Encodings = { get ExpertEncoding() { return shadow(this, 'ExpertEncoding', ['', '', '', '', '', '', '', '', '', @@ -762,8 +774,8 @@ var Font = (function FontClosure() { var names = name.split('+'); names = names.length > 1 ? names[1] : names[0]; names = names.split(/[-,_]/g)[0]; - this.isSerifFont = !!(properties.flags & 2); - this.isSymbolicFont = !!(properties.flags & 4); + this.isSerifFont = !!(properties.flags & FontFlags.Serif); + this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic); var type = properties.type; this.type = type;