From 04e467793b79f8403d499748dc33f1f9f58ee09f Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Mon, 10 Oct 2011 21:14:40 -0500 Subject: [PATCH 1/4] Fixing standard font name resolution (#649) --- fonts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fonts.js b/fonts.js index 2ab3a90b7..7aef5ec92 100644 --- a/fonts.js +++ b/fonts.js @@ -441,7 +441,7 @@ var Font = (function Font() { if (!file) { // The file data is not specified. Trying to fix the font name // to be used with the canvas.font. - var fontName = stdFontMap[name] || name.replace('_', '-'); + var fontName = stdFontMap[name.replace('-', '_')] || name.replace('_', '-'); this.bold = (fontName.search(/bold/gi) != -1); this.italic = (fontName.search(/oblique/gi) != -1) || (fontName.search(/italic/gi) != -1); From 1f532e6edbda223144e4f7558f352661f7c2c514 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Mon, 10 Oct 2011 22:40:43 -0500 Subject: [PATCH 2/4] Long line fix --- fonts.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fonts.js b/fonts.js index 7aef5ec92..1c0039264 100644 --- a/fonts.js +++ b/fonts.js @@ -441,7 +441,8 @@ var Font = (function Font() { if (!file) { // The file data is not specified. Trying to fix the font name // to be used with the canvas.font. - var fontName = stdFontMap[name.replace('-', '_')] || name.replace('_', '-'); + var fontName = stdFontMap[name.replace('-', '_')] || + name.replace('_', '-'); this.bold = (fontName.search(/bold/gi) != -1); this.italic = (fontName.search(/oblique/gi) != -1) || (fontName.search(/italic/gi) != -1); From e745114a5e13b5a6e842d502cfd2bddba6381f03 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Tue, 11 Oct 2011 19:38:20 -0500 Subject: [PATCH 3/4] Making the normalized name same in pdf.js and fonts.js --- fonts.js | 83 ++++++++++++++++++++++++++++---------------------------- pdf.js | 2 +- 2 files changed, 43 insertions(+), 42 deletions(-) diff --git a/fonts.js b/fonts.js index 1c0039264..120e5111c 100644 --- a/fonts.js +++ b/fonts.js @@ -26,53 +26,53 @@ var kHintingEnabled = false; */ var stdFontMap = { 'ArialNarrow': 'Helvetica', - 'ArialNarrow_Bold': 'Helvetica-Bold', - 'ArialNarrow_BoldItalic': 'Helvetica-BoldOblique', - 'ArialNarrow_Italic': 'Helvetica-Oblique', + 'ArialNarrow-Bold': 'Helvetica-Bold', + 'ArialNarrow-BoldItalic': 'Helvetica-BoldOblique', + 'ArialNarrow-Italic': 'Helvetica-Oblique', 'ArialBlack': 'Helvetica', - 'ArialBlack_Bold': 'Helvetica-Bold', - 'ArialBlack_BoldItalic': 'Helvetica-BoldOblique', - 'ArialBlack_Italic': 'Helvetica-Oblique', + 'ArialBlack-Bold': 'Helvetica-Bold', + 'ArialBlack-BoldItalic': 'Helvetica-BoldOblique', + 'ArialBlack-Italic': 'Helvetica-Oblique', 'Arial': 'Helvetica', - 'Arial_Bold': 'Helvetica-Bold', - 'Arial_BoldItalic': 'Helvetica-BoldOblique', - 'Arial_Italic': 'Helvetica-Oblique', - 'Arial_BoldItalicMT': 'Helvetica-BoldOblique', - 'Arial_BoldMT': 'Helvetica-Bold', - 'Arial_ItalicMT': 'Helvetica-Oblique', + 'Arial-Bold': 'Helvetica-Bold', + 'Arial-BoldItalic': 'Helvetica-BoldOblique', + 'Arial-Italic': 'Helvetica-Oblique', + 'Arial-BoldItalicMT': 'Helvetica-BoldOblique', + 'Arial-BoldMT': 'Helvetica-Bold', + 'Arial-ItalicMT': 'Helvetica-Oblique', 'ArialMT': 'Helvetica', - 'Courier_Bold': 'Courier-Bold', - 'Courier_BoldItalic': 'Courier-BoldOblique', - 'Courier_Italic': 'Courier-Oblique', + 'Courier-Bold': 'Courier-Bold', + 'Courier-BoldItalic': 'Courier-BoldOblique', + 'Courier-Italic': 'Courier-Oblique', 'CourierNew': 'Courier', - 'CourierNew_Bold': 'Courier-Bold', - 'CourierNew_BoldItalic': 'Courier-BoldOblique', - 'CourierNew_Italic': 'Courier-Oblique', - 'CourierNewPS_BoldItalicMT': 'Courier-BoldOblique', - 'CourierNewPS_BoldMT': 'Courier-Bold', - 'CourierNewPS_ItalicMT': 'Courier-Oblique', + 'CourierNew-Bold': 'Courier-Bold', + 'CourierNew-BoldItalic': 'Courier-BoldOblique', + 'CourierNew-Italic': 'Courier-Oblique', + 'CourierNewPS-BoldItalicMT': 'Courier-BoldOblique', + 'CourierNewPS-BoldMT': 'Courier-Bold', + 'CourierNewPS-ItalicMT': 'Courier-Oblique', 'CourierNewPSMT': 'Courier', - 'Helvetica_Bold': 'Helvetica-Bold', - 'Helvetica_BoldItalic': 'Helvetica-BoldOblique', - 'Helvetica_Italic': 'Helvetica-Oblique', - 'Symbol_Bold': 'Symbol', - 'Symbol_BoldItalic': 'Symbol', - 'Symbol_Italic': 'Symbol', + 'Helvetica-Bold': 'Helvetica-Bold', + 'Helvetica-BoldItalic': 'Helvetica-BoldOblique', + 'Helvetica-Italic': 'Helvetica-Oblique', + 'Symbol-Bold': 'Symbol', + 'Symbol-BoldItalic': 'Symbol', + 'Symbol-Italic': 'Symbol', 'TimesNewRoman': 'Times-Roman', - 'TimesNewRoman_Bold': 'Times-Bold', - 'TimesNewRoman_BoldItalic': 'Times-BoldItalic', - 'TimesNewRoman_Italic': 'Times-Italic', + 'TimesNewRoman-Bold': 'Times-Bold', + 'TimesNewRoman-BoldItalic': 'Times-BoldItalic', + 'TimesNewRoman-Italic': 'Times-Italic', 'TimesNewRomanPS': 'Times-Roman', - 'TimesNewRomanPS_Bold': 'Times-Bold', - 'TimesNewRomanPS_BoldItalic': 'Times-BoldItalic', - 'TimesNewRomanPS_BoldItalicMT': 'Times-BoldItalic', - 'TimesNewRomanPS_BoldMT': 'Times-Bold', - 'TimesNewRomanPS_Italic': 'Times-Italic', - 'TimesNewRomanPS_ItalicMT': 'Times-Italic', + 'TimesNewRomanPS-Bold': 'Times-Bold', + 'TimesNewRomanPS-BoldItalic': 'Times-BoldItalic', + 'TimesNewRomanPS-BoldItalicMT': 'Times-BoldItalic', + 'TimesNewRomanPS-BoldMT': 'Times-Bold', + 'TimesNewRomanPS-Italic': 'Times-Italic', + 'TimesNewRomanPS-ItalicMT': 'Times-Italic', 'TimesNewRomanPSMT': 'Times-Roman', - 'TimesNewRomanPSMT_Bold': 'Times-Bold', - 'TimesNewRomanPSMT_BoldItalic': 'Times-BoldItalic', - 'TimesNewRomanPSMT_Italic': 'Times-Italic' + 'TimesNewRomanPSMT-Bold': 'Times-Bold', + 'TimesNewRomanPSMT-BoldItalic': 'Times-BoldItalic', + 'TimesNewRomanPSMT-Italic': 'Times-Italic' }; var serifFonts = { @@ -441,8 +441,9 @@ var Font = (function Font() { if (!file) { // The file data is not specified. Trying to fix the font name // to be used with the canvas.font. - var fontName = stdFontMap[name.replace('-', '_')] || - name.replace('_', '-'); + var fontName = name.replace(/,_/g, '-'); + fontName = stdFontMap[fontName] || fontName; + this.bold = (fontName.search(/bold/gi) != -1); this.italic = (fontName.search(/oblique/gi) != -1) || (fontName.search(/italic/gi) != -1); diff --git a/pdf.js b/pdf.js index 847ed2ff4..311194208 100644 --- a/pdf.js +++ b/pdf.js @@ -4783,7 +4783,7 @@ var PartialEvaluator = (function partialEvaluator() { return null; // Using base font name as a font name. - baseFontName = baseFontName.name.replace(/,/g, '_'); + baseFontName = baseFontName.name.replace(/,_/g, '-'); var metricsAndMap = this.getBaseFontMetricsAndMap(baseFontName); var properties = { From fae8459991951c4b7466bfc9ca10a45d3b69ce98 Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Tue, 11 Oct 2011 19:45:55 -0500 Subject: [PATCH 4/4] Add standard font name test (also for #621) --- test/pdfs/pal-o47.pdf.link | 1 + test/test_manifest.json | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 test/pdfs/pal-o47.pdf.link diff --git a/test/pdfs/pal-o47.pdf.link b/test/pdfs/pal-o47.pdf.link new file mode 100644 index 000000000..e45c4873d --- /dev/null +++ b/test/pdfs/pal-o47.pdf.link @@ -0,0 +1 @@ +http://www1.cpdl.org/wiki/images/sheet/pal-o47.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 43b799bad..3ede43ceb 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -199,6 +199,12 @@ "rounds": 1, "type": "eq" }, + { "id": "pal-o47", + "file": "pdfs/pal-o47.pdf", + "link": true, + "rounds": 1, + "type": "eq" + }, { "id": "simpletype3font", "file": "pdfs/simpletype3font.pdf", "link": false,