mozilla/pdf.js — pull request #4944 by Snuffleupagus (2014-06-14 21:37:35+00:00)
Title: Don't blindly trust toUnicode when building toFontChar for non-standard fonts without a font file (issue 4934)

*This PR does fix the issue, and it passes all tests locally, however I am really not sure if this is the correct way to solve the issue.*

For non-standard fonts without font files, relying solely on `toUnicode` when building `toFontChar` can be problematic since `toUnicode` may contain strange/bogus entries.
In the PDF file in the issue referenced below, `toUnicode` actually maps most upper-case letters to their lower-case versions.
I've attempted to solve this by instead checking `differences` and `defaultEncoding` before accepting a `toUnicode` entry.

*Please note*: this seemed to break the character mapping when used with `CIDFontType` fonts, hence it's not used in those cases. This distinction seemed somewhat arbitrary, but before PR #4259 those fonts were apparently handled slightly differently than other fonts.

Fixes #4934.