Skip to content

Track the scope of @font-face families in PDF as a gap - #303

Merged
eXpl0it3r merged 1 commit into
masterfrom
spec/font-face-family-scope
Nov 26, 2026
Merged

eXpl0it3r merged 1 commit into
masterfrom
spec/font-face-family-scope

Conversation

@eXpl0it3r

Copy link
Copy Markdown
Collaborator

Description

CSS Fonts 4 §4.2 says, that an @font-face family named like an installed family hides the installed one "for documents that use the stylesheet". The PdfSharp backend gets both halves of that wrong, so #font-family-desc goes from supported to partial with two gaps and an ignored test each:

  • A face named like a system family only replaces the system face with the same weight, style and stretch. An @font-face "Book Antiqua" with only a 400 face still resolves bold to the installed "Book Antiqua Bold", instead of the registered face with synthesized bold.
  • A face stays registered for the whole process, because PdfSharpAdapter is a singleton with a single FontResolver and nothing ever removes a face. A later document that uses the same family name without declaring it still embeds the webfont.

The second one is the more serious one, on a server one user's document can change the fonts of another user's PDF. Fixing it needs a font set per document instead of per adapter, which is a bigger change, as such this PR only tracks it. The screen adapters likely have the same leak through the shared FontsHandler, that's not tested yet.

How to test this PR?

CI should succeed. Removing the [Ignore] from the two tests in FontFaceFamilyTests makes both fail at their assertion.

@eXpl0it3r eXpl0it3r added the PDF label Nov 26, 2026
@eXpl0it3r
eXpl0it3r merged commit 6ff1dfc into master Nov 26, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant