Merge pull request #190 from helmuthb/dev/encoding-standardfonts

Support for latin1-special characters and euro-sign with standard fonts
This commit is contained in:
Devon Govett 2014-01-18 13:12:59 -08:00
commit a157b466a6

View File

@ -33,8 +33,50 @@ class PDFFont
return fn() if @isAFM
@embedTTF fn
_WinAnsiMap: {
402: 131
8211: 150
8212: 151
8216: 145
8217: 146
8218: 130
8220: 147
8221: 148
8222: 132
8224: 134
8225: 135
8226: 149
8230: 133
8364: 128
8240: 137
8249: 139
8250: 155
710: 136
8482: 153
338: 140
339: 156
732: 152
352: 138
353: 154
376: 159
381: 142
382: 158
}
_encodeWinAnsi: (text) ->
string = ''
for i in [0...text.length]
char = text.charCodeAt(i)
char = @_WinAnsiMap[char] || char
string += String.fromCharCode(char)
return string
encode: (text) ->
@subset?.encodeText(text) or text
if @isAFM
@_encodeWinAnsi text
else
@subset?.encodeText(text) or text
registerTTF: ->
@scaleFactor = 1000.0 / @ttf.head.unitsPerEm
@ -173,6 +215,7 @@ class PDFFont
Type: 'Font'
BaseFont: @filename
Subtype: 'Type1'
Encoding: 'WinAnsiEncoding'
_standardFonts: [
"Courier"
@ -205,4 +248,4 @@ class PDFFont
gap = if includeGap then @lineGap else 0
(@ascender + gap - @decender) / 1000 * size
module.exports = PDFFont
module.exports = PDFFont