From 1a1505071cc09854d0acceed88ba8389b81b3643 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Thu, 13 Aug 2026 18:07:57 +0200 Subject: [PATCH] fix: the parity reference stops depending on which duplicate font it picks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A second copy of a family LibreOffice bundles makes its render non-deterministic: it resolves the same family to either file per run — the PDF names them Carlito and Carlito-Regular — and their vertical metrics differ, so a page led by a large-font heading lands 1.85mm lower on some runs. Measured 5/5 identical once the duplicates were gone, against a 2-of-4 flip before, and one fixture's count swinging 21↔62 with no code change. README now says to install only what the local LibreOffice does not already ship. Also skips the `~$name` lock file a word processor leaves beside a fixture it has open, which the corpus was picking up as a document. --- tests/render-parity/README.md | 10 ++++++++++ tests/render-parity/run.mjs | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/render-parity/README.md b/tests/render-parity/README.md index 85849f8..d83dbb8 100644 --- a/tests/render-parity/README.md +++ b/tests/render-parity/README.md @@ -45,6 +45,16 @@ line breaks differently for a reason that is not a bug. With them, both engines resolve Times New Roman → Liberation Serif, Arial → Liberation Sans, Calibri → Carlito, Cambria → Caladea — the same files the editor bundles. +**But install only what LibreOffice does not already ship.** A second copy of a +family it bundles makes its render *non-deterministic*: it picks between the two +files per run — measured as `Carlito` against `Carlito-Regular` in the PDF's font +list — and their vertical metrics differ, so a page carrying a large-font heading +lands 1.85mm lower on some runs and a fixture's issue count swings by 40. The +browser side never needs the install: the app `@font-face`s its own copies. On a +macOS install `/Applications/LibreOffice.app/Contents/Resources/fonts/truetype/` +already holds Carlito, Caladea and Liberation, so **skip the `cp` there entirely**; +check any other platform with `fc-list | grep -ci carlito` before copying. + The runner starts `npm run dev` on port 5199 itself if nothing answers there. ## Fixtures diff --git a/tests/render-parity/run.mjs b/tests/render-parity/run.mjs index 07048c3..0fce760 100644 --- a/tests/render-parity/run.mjs +++ b/tests/render-parity/run.mjs @@ -275,7 +275,9 @@ function corpus(args) { const stat = existsSync(abs) && readdirSync(dirname(abs)).length >= 0; if (!stat) continue; try { - for (const f of readdirSync(abs)) if (/\.(docx|odt)$/i.test(f)) out.push(join(abs, f)); + // `~$name` is the lock file a word processor leaves beside a document it has open — + // opening a fixture to compare it by eye would otherwise add it to the corpus. + for (const f of readdirSync(abs)) if (/\.(docx|odt)$/i.test(f) && !f.startsWith('~$')) out.push(join(abs, f)); } catch { out.push(abs); } } return out.sort();