Add basic support for non-embedded Wingdings fonts

This is a tentative patch that adds *very* basic support for non-embedded Wingdings fonts (a Windows version of Dingbats), by falling back to the ZapfDingbats encoding. Obviously this approach will not work perfectly, but in my opinion it seems to work reasonably well in pratice.

Instead of this very simple patch, another option would be to try and include more complete glyph data for Wingdings, e.g. a Unicode map and glyph widths, similar to what was done for ZapfDingbats.
However there is, in my opinion, one important difference between Wingdings and ZapfDingbats: ZapfDingbats is part of the 14 standard fonts, which in previous versions of the PDF specification was assumed to be available in PDF readers. To improve compatibility with older files, it thus makes sense for us to include data for ZapfDingbats.
However Wingdings has never been a standard font in PDF files, hence PDF files using it *should* thus contain all the necessary font data.

Given the above, I thus believe that it should be OK to fall back to ZapfDingbats for now. If non-embedded Wingdings fonts turns out to be *a lot* more common, then we can revisit this later.

Fixes 4301 completely.
Fixes 4837 almost completely. With this patch the bullets are displayed correctly, but the arrows are not of the correct type.
Fixes `artofwar.pdf`, pages 14 and 15.
This commit is contained in:
Jonas Jenwald 2014-11-01 13:08:26 +01:00
parent 35474628e3
commit 96a77e9d6a

View File

@ -371,7 +371,8 @@ var nonStdFontMap = {
'MS-PMincho': 'MS PMincho',
'MS-PMincho-Bold': 'MS PMincho-Bold',
'MS-PMincho-BoldItalic': 'MS PMincho-BoldItalic',
'MS-PMincho-Italic': 'MS PMincho-Italic'
'MS-PMincho-Italic': 'MS PMincho-Italic',
'Wingdings': 'ZapfDingbats'
};
var serifFonts = {
@ -2500,6 +2501,10 @@ var Font = (function FontClosure() {
this.toFontChar[charCode] = fontChar;
}
} else if (/Dingbats/i.test(fontName)) {
if (/Wingdings/i.test(name)) {
warn('Wingdings font without embedded font file, ' +
'falling back to the ZapfDingbats encoding.');
}
var dingbats = Encodings.ZapfDingbatsEncoding;
for (charCode in dingbats) {
fontChar = DingbatsGlyphsUnicode[dingbats[charCode]];