opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.5k stars 479 forks source link

Support of subset-fonts #426

Open r-pf opened 4 years ago

r-pf commented 4 years ago

Fonts.zip

The attached file BAAAAA+Bauhaus93.ttf was extracted from a PDF. It was build as subset of BAUHS93.TTF and contains only the glyphs used by "Hello World" (=> 'H', 'e', 'l', 'o', ' ', 'W', 'r', 'd').

Expected Behavior

Is it possible to extend opentype.js to support such subset-fonts also.

Current Behavior

Currently an error-messae occured: Error: No valid cmap sub-tables found.

Possible Solution

fontforge can open BAAAAA+Bauhaus93.ttf and view the glyphs of it.

Steps to Reproduce (for bugs)

  1. Open https://opentype.js.org/index.html
  2. Open BAAAAA+Bauhaus93.ttf
  3. The error-message occured

Context

Your Environment

ceztko commented 3 years ago

+1 . According to ISO 32000:2008 (PDF 1.7):

A TrueType font program may be used as part of either a font or a CIDFont. Although the basic font file format is the same in both cases, there are different requirements for what information shall be present in the font program. These TrueType tables shall always be present if present in the original TrueType font program: “head”, “hhea”, “loca”, “maxp”, “cvt”, “prep”, “glyf”, “hmtx”, and “fpgm”. If used with a simple font dictionary, the font program shall additionally contain a cmap table defining one or more encodings, as discussed in 9.6.6.4, "Encodings for TrueType Fonts". If used with a CIDFont dictionary, the cmap table is not needed and shall not be present, since the mapping from character codes to glyph descriptions is provided separately.

The following font is a valid subset used in a pdf (both attached).

FontSubset.zip TestSubset.pdf

Connum commented 11 months ago

See #643