Fix PDF export heading font fallback #6069

Merged
alexwoo-awso merged 1 commit from fix/pdf-export-heading-fonts into development 2026-04-20 15:33:01 +02:00
alexwoo-awso commented 2026-03-25 15:26:18 +01:00 (Migrated from github.com)

PDF exports used the heading font var which in DOMPDF fell back to base fonts lacking Polish glyphs, causing ? in titles. This PR adds a PDF-only heading font fallback to DejaVu Sans for h1-h6. Tested by exporting a page with a Polish title; characters render correctly.

Before
image
image

After
image
image

PDF exports used the heading font var which in DOMPDF fell back to base fonts lacking Polish glyphs, causing ? in titles. This PR adds a PDF-only heading font fallback to DejaVu Sans for h1-h6. Tested by exporting a page with a Polish title; characters render correctly. Before <img width="792" height="386" alt="image" src="https://github.com/user-attachments/assets/e8ad4668-f121-4c6b-b5b1-c75bb1fbeb8a" /> <img width="803" height="406" alt="image" src="https://github.com/user-attachments/assets/63c4cd84-ab8f-4171-977d-76c4f06556f3" /> After <img width="774" height="417" alt="image" src="https://github.com/user-attachments/assets/b5ab423f-4fd4-4929-a7fc-ef8945998e38" /> <img width="760" height="539" alt="image" src="https://github.com/user-attachments/assets/aae6bfb0-cd5a-4437-b3fc-c2e33a2fd7fd" />
janusz-net commented 2026-04-08 10:58:13 +02:00 (Migrated from github.com)

The problem lies elsewhere. The last version that didn't have a problem with Polish characters in headers was v25.02.2. After updating to v25.02.3, "zażółć gęśli jaźń" -> "za?ół?? g??l? ja??.". The only change that causes this error is at the very beginning of the public/dist/export-styles.css file:

.dummy-style{color:red}:root{--font-body:...

Removing .dummy-style{color:red} makes Polish characters in PDF headers correct again.

The problem lies elsewhere. The last version that didn't have a problem with Polish characters in headers was v25.02.2. After updating to v25.02.3, "zażółć gęśli jaźń" -> "za?ół?? g??l? ja??.". The only change that causes this error is at the very beginning of the `public/dist/export-styles.css` file: ```css .dummy-style{color:red}:root{--font-body:... ``` Removing `.dummy-style{color:red}` makes Polish characters in PDF headers correct again.
alexwoo-awso commented 2026-04-09 17:13:47 +02:00 (Migrated from github.com)

@janusz-net Removing .dummy-style{color:red} would likely reintroduce the earlier BOM-related issue tracked in https://github.com/sass/dart-sass/issues/472.

Your observation is still useful though, since it shows the PDF export path is sensitive to the first rule in the inlined export-styles.css; this PR aims to fix that without regressing the earlier workaround.

@janusz-net Removing .dummy-style{color:red} would likely reintroduce the earlier BOM-related issue tracked in https://github.com/sass/dart-sass/issues/472. Your observation is still useful though, since it shows the PDF export path is sensitive to the first rule in the inlined export-styles.css; this PR aims to fix that without regressing the earlier workaround.
ssddanbrown commented 2026-04-20 15:34:37 +02:00 (Migrated from github.com)

Thanks @alexwoo-awso, now merged. I did make a slight change afterwards in 4f370ccddb to set this for all exports so that it's aligned with what we're doing for fonts on other text.

Thanks @alexwoo-awso, now merged. I did make a slight change afterwards in 4f370ccddb4f5fd8eddff5915a9413786ae2a2c7 to set this for all exports so that it's aligned with what we're doing for fonts on other text.
Sign in to join this conversation.
No description provided.