Skip to content

[watermark] embed a bundled font so stamped PDFs are reproducible#350

Merged
norbusan merged 1 commit into
masterfrom
watermark-reproducible-font
Jul 8, 2026
Merged

[watermark] embed a bundled font so stamped PDFs are reproducible#350
norbusan merged 1 commit into
masterfrom
watermark-reproducible-font

Conversation

@norbusan

@norbusan norbusan commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

_build_watermark_overlay measures the watermark's true glyph extent by rasterizing it (pdf_oxide render_pixmap -> Pillow getbbox) and uses that extent to place the stamp. With the default base-14 "Times-Roman" - which carries no font program - pdf_oxide rasterizes with whatever font it finds on the host, so the measured extent, and thus the stamp position, differs from machine to machine. The resulting PDF is therefore not byte-identical across a dev box, CI, and production, which breaks the reproducible-build checksum tests downstream (arxiv-converter genpdf).

Embed a bundled Nimbus Roman (URW's metrically-Times-compatible face, the Ghostscript default Times substitute) whenever the caller passes no custom font. pdf_oxide then rasterizes the embedded face itself, independent of host fonts, so the measurement - and the output - is identical everywhere. As a bonus the stamp now renders consistently in every PDF viewer instead of relying on a base-14 substitution.

Verified byte-identical output between an Arch host and a fontless Debian container (differed before, identical after). The font is AGPL-3.0-only WITH PS-or-PDF-font-exception-20170817, which explicitly permits embedding and redistribution; the license text ships alongside it.

_build_watermark_overlay measures the watermark's true glyph extent by
rasterizing it (pdf_oxide render_pixmap -> Pillow getbbox) and uses that
extent to place the stamp. With the default base-14 "Times-Roman" - which
carries no font program - pdf_oxide rasterizes with whatever font it finds
on the host, so the measured extent, and thus the stamp position, differs
from machine to machine. The resulting PDF is therefore not byte-identical
across a dev box, CI, and production, which breaks the reproducible-build
checksum tests downstream (arxiv-converter genpdf).

Embed a bundled Nimbus Roman (URW's metrically-Times-compatible face, the
Ghostscript default Times substitute) whenever the caller passes no custom
font. pdf_oxide then rasterizes the embedded face itself, independent of
host fonts, so the measurement - and the output - is identical everywhere.
As a bonus the stamp now renders consistently in every PDF viewer instead
of relying on a base-14 substitution.

Verified byte-identical output between an Arch host and a fontless Debian
container (differed before, identical after). The font is AGPL-3.0-only
WITH PS-or-PDF-font-exception-20170817, which explicitly permits embedding
and redistribution; the license text ships alongside it.
@norbusan
norbusan merged commit 941cd69 into master Jul 8, 2026
1 check passed
@norbusan
norbusan deleted the watermark-reproducible-font branch July 8, 2026 14:44
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

Successfully merging this pull request may close these issues.

1 participant