Urgent.News

What's breaking now, across thousands of outlets.

Tech

A font-license checkpoint for PDF-to-HTML: what fsType can and can't tell you

If you convert PDFs into web pages, someone eventually asks whether you are allowed to put the PDF's fonts into the HTML. The obvious design is a checkpoint that reads the font's license flag and stops the pipeline when it says no. Looking at what actually arrives at that point changed where I would put the check. The flag is fsType, a 16-bit field in the font's OS/2 table. Per the OpenType spec…

When converting PDFs into web pages, a question arises about the legality of embedding the PDF's fonts into the HTML. Traditionally, a checkpoint would examine the font's license flag and halt the process if the flag indicated no embedding. However, the specific flag examined—fsType—yielded surprising results.

fsType is a 16-bit field within the font's OS/2 table. According to the OpenType specification, bits 0-3 indicate usage permissions, with valid values of 0, 2, 4, and 8. Bit 8 signifies no subsetting, while bit 9 denotes bitmap embedding only. The fonts examined, including Pacifico, Liberation Sans, Helvetica, and Noto Serif SC, only had values of 0, 4, or 8. Values 2, 256, and 512 were found only in test copies made by editing font files.

The producer may have already decided on the font usage, as demonstrated by printing the same bilingual page to PDF using Chromium 149 with Pacifico and Liberation Sans copies at each fsType. In the PDF files, TrueType fonts with fsType 2 or 512 were not embedded at all, and instead, their glyphs were rendered as Type 3 outlines. With fsType 256, the entire font was embedded without subsetting, while fsType 0, 4, and 8 resulted in a normal subset.

After testing, the converter reading a Chromium-printed PDF found no fonts explicitly stating "do not embed." The restriction had been applied upstream, leaving only three types of font programs in the final output. These types included a TrueType subset inlined as woff fonts with only the used glyphs, a Type 3 outline, and a Type 1 system font fallback.

In a sample brochure, the converter from Wiki Education Foundation processed five lines, with three of them featuring a font with no fsType flag (indicating no subsetting). The trueType subsets were inlined as woff fonts, while the Type 1 font was not inlined, causing text elements to fall back to a generic sans-serif. Type 3 glyphs became vector paths, and in some cases, the font in the PDF changed to a different shape.

The cost of each method varied. For TrueType subsets, the text remained selectable, using only the vectors that appeared on the pages. For Type 3 outlines, paths with transparent text layers were used, and the shape of the font was preserved. In the case of Type 1 fonts, the shape changed, and no font file was embedded.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why Saying ‘Hi’ to Our OpenCode Agent Used 177,000 Tokens

At Bold.org, people use our internal company agent to investigate production issues, look up information, and put together reports.

  • Agent used 177,000 tokens for simple "hi" greeting
  • Astra model caused high token consumption growth
  • Disabling Meta Ads reduced token usage by 69%

More from Thursday 29 October →