Skip to content

Kernel: a font subset's tag is a hash of its glyph ids alone, so two different fonts that show the same glyph ids share a tag #754

Backlog

Description

@Tim81

Why

ISO 32000-1, 9.6.4: the tag is six uppercase letters, "different subsets in the same PDF file shall have different tags". ISO 32000-2, 9.9.2 narrows it: "different subsets of the same font in the same PDF file shall have different tags". TrueTypeFontEmbedder.SubsetTag hashes the sorted glyph ids and nothing else.

Measured on origin/main 8c39d8d: the Liberation Sans Regular and Bold programs from Standard14Substitutes.GetFontProgram, both drawing "Hello" in one Kernel page. The two fonts get the same tag and differ after the plus sign (six capitals, then +LiberationSans and +LiberationSans-Bold; Iso32000_2_9_9_2_TwoSubsetsOfOneFontInOneFileShareAnEmbeddedFontAndSoOneTag asserts the equal tags). The two Liberation faces number their Latin glyphs alike; other families were not measured, so how common the clash is in general is open. Two registrations of one program return one handle, so the file never holds two subsets of the same font under one tag, which is what the 32000-2 sentence asks for.

No oracle checks it: veraPDF 1.30.4 has no rule for the tag's uniqueness.

Sweep: git grep -n SubsetTag over src on origin/main finds one definition and one use in TrueTypeFontEmbedder.cs, which names the Type 0 font, the CIDFont and the descriptor. CffSubsetter.ComputeSubsetTag repeats the same hash for the font name inside a CFF program, from the same glyph set, so the two agree (Iso32000_1_9_7_4_1_ACffCidFontIsNamedLikeItsProgram) and both need the change. No other package builds a subset name.

Proposal

Mix the font program's hash (EmbeddedFontHandle.FontHash already exists) into the tag input, so two fonts never share a tag unless they are the same program with the same glyphs. The tag stays six capitals and stays deterministic. Every embedded font in every file changes its name by the tag, which moves the golden files and any byte comparison, so this belongs in a release that already changes the output.

Acceptance

  • The two Liberation faces drawing the same glyph ids get different tags; the pinned test is rewritten to assert it.
  • The same font and glyphs still give the same tag on every run and runtime.

Activity

  1. added
    bug
    on Nov 28, 2026
  2. Tim81 commented on Nov 29, 2026

    @Tim81
    OwnerAuthor

    The ISO audit (docs/conformance-v2.4.md) has skipped tests that wait on this issue; the fix removes their skip and makes them pass.

    • Iso32000_1_9_6_4_TwoSubsetsOfDifferentFontsHaveDifferentTags (group G2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions