PDF.js/fonts

From MozillaWiki
Jump to: navigation, search

Documentation

  • Adobe Developer Network [1]
  • OpenType Specification [2]

General

Embedded fonts are extracted from the PDF file before being loaded via a @font-face rule. Once a font is ready, it can be used to to draw the character on the canvas.

The font loaded via @font-face is verified by the OpenType font sanitizer, if something is wrong, the font is rejected.

If the font if missing for the file, because for example it is one of the standard 14 fonts as defined by Adobe, the systems fonts are used. If the missing font is not one of this 14 fonts, a fallback font is used. In Acrobat Reader this font is 'Adobe Sans MM' or 'Adobe Serif MM', in pdf.js the font is decided by the system (for example on Linux it used fontconfig to determine which font to used).

  • Chrome, Firefox and probably others use the OpenType Sanitizer Library. [3]
  • For testing purpose it is possible to disable the sanitizer by switching the preference 'gfx.downloadable_fonts.sanitize' to 'false' on Firefox


Simple Fonts

Type1

  • Basic Support thought the conversion to an opentype font
  • Support for hinting and hint replacement are missing or buggy

TrueType

  • Supported

Font subsets

  • Supported

Type3

  • Missing

Composite Fonts

CIDFontType0

  • Predefined CMap parsing is missing

CIDFontType2

  • Partially supported