Skip to content

Output fails ots-sanitize, can’t be loaded in Firefox nightly #98

Open
@andersk

Description

After processing a TrueType font with fontmin --text, the output can’t be loaded as a web font in Firefox nightly. This is because the output fails the validation enabled by the gfx.downloadable_fonts.otl_validation preference, which is true by default in Firefox nightly. This can also be reproduced using the standalone OpenType Sanitizer project on which Firefox’s validation is based.

Reproduction steps

Install OpenType Sanitizer.

$ git clone https://github.com/khaledhosny/ots.git
$ cd ots
$ meson build
$ ninja -C build
$ ninja -C build install
$ cd ..

Downgrade get-stdin and meow in fontmin to work around #97.

$ git clone https://github.com/ecomfe/fontmin.git
$ cd fontmin
$ npm i get-stdin@^8 meow@^9

Get a font, and demonstrate that it passes sanitization.

$ curl -LO 'https://github.com/adobe-fonts/source-sans/raw/3.046R/TTF/SourceSans3-Bold.ttf'
$ ots-sanitize SourceSans3-Bold.ttf sanitized.ttf
File sanitized successfully!

Process the font with fontmin, and demonstrate that the result fails sanitization.

$ ./cli.js --text abc SourceSans3-Bold.ttf > out.ttf
$ ots-sanitize out.ttf sanitized.ttf
ERROR at ../src/layout.cc:380 (ParseCoverageFormat2)
ERROR: Layout: bad range count: 8
ERROR at ../src/gpos.cc:631 (ParseMarkToAttachmentSubtables)
ERROR: GPOS: Failed to parse converge 1 table
ERROR at ../src/layout.cc:1178 (Parse)
ERROR: Layout: Failed to parse lookup subtable 3
ERROR at ../src/layout.cc:240 (ParseLookupTable)
ERROR: Layout: Failed to parse subtable 0
ERROR at ../src/layout.cc:1328 (ParseLookupListTable)
ERROR: Layout: Failed to parse lookup 0
ERROR: GPOS: Failed to parse lookup list table
ERROR at ../src/ots.cc:711 (ProcessGeneric)
ERROR: GPOS: Failed to parse table
Failed to sanitize file!

Alternatively, write an HTML file that uses the output font and view it in Firefox nightly. The output font is not displayed, and a corresponding set of errors shows up in the browser console.

<!-- test.html -->
<meta charset="UTF-8" />
<style>
  @font-face {
    font-family: InputFont;
    src: url(SourceSans3-Bold.ttf);
  }
  @font-face {
    font-family: OutputFont;
    src: url(out.ttf);
  }
</style>
<div style="font-family: InputFont">abc</div>
<div style="font-family: OutputFont">abc</div>

Screenshot from 2021-10-25 19-19-43

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions