Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andersk opened this issue Oct 26, 2021 · 0 comments
Open

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

andersk opened this issue Oct 26, 2021 · 0 comments

Comments

@andersk
Copy link
Contributor

andersk commented Oct 26, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant