Text gradient in a zero-height block is invisible in PDF
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
Research direction
Read crates/typst-pdf/src/paint.rs, especially convert_paint around lines 97–102 and convert_gradient around line 209; trace how the adjusted paint size and state.container_size() determine the gradient matrix. Reproduce the zero-height block and compare its PDF output with a block that has height. Done when the zero-height text gradient renders in PDF from red to blue without a singular matrix.
Written by the indexing model from the issue text.
Description
Description
This exports a shading pattern with a singular matrix:
#block(height: 0pt, text(fill: gradient.linear(red, blue))[Gradient text])
The PDF contains /Matrix [59.488 0 0 0 70.86614 771.0236].
- Ghostscript 10.08.0: the page is blank.
- poppler 26.11.0 (
pdftocairo): printsSyntax Warning: matrix not invertibleand the page is blank. - PNG export: the text is solid red.
A one-line heading under #set text(top-edge: "baseline") also has zero height and gives a singular matrix.
convert_paint in crates/typst-pdf/src/paint.rs replaces a zero size with 1 pt (L97–102), but convert_gradient then uses state.container_size() for RelativeTo::Parent (L209), which still has the zero height. The code is the same on main.
Expected: the gradient shows from red to blue, as in a block with a height.
Reproduction URL
none
Operating system
macOS
Typst version
- I am using the latest version of Typst (0.15.1)
- Dominant language
- Rust
- Stars
- 57k
- Forks
- 1.8k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 22
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from typst/typst
-
feature request
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 2 days
-
bug foundations
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
typst/typst#9047 · 2 comments · 2 reactions ·
Maintainers usually reply within 2 days
-
docs-infra
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
typst/typst#9020 · 2 comments ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
typst/typst#8987 · 1 comment ·
Maintainers usually reply within 2 days
-
docs-infra
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
typst/typst#8934 · 2 comments ·
Maintainers usually reply within 2 days
Similar issues
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
swc-project/swc-ai-issues#907 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
-
area:helper kind:bug priority:p3 ready
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug UI
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
wardian-app/Wardian#1746 ·
Maintainers usually reply within 1 day