From 96a77e9d6acdad45d3545a45ddb774883fe4e9a6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 1 Nov 2014 13:08:26 +0100 Subject: [PATCH] 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. --- src/core/fonts.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index b173e02eb..0146151e6 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -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]];