OpenPrinting / OpenPrinting/libcupsfilters
texttopdf embeds a font without checking it covers the text, printing every glyph as .notdef
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17
- Forks
- 71
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 13
Description
Symptom
With powerline-fonts installed, printing any plain text file produces a page where every character is a hollow box. Every application is affected, since they all go through the same filter.
Cause
cfFilterTextToPDF resolves monospace through fontconfig once for the whole document and embeds whatever comes back, without checking whether that font has glyphs for the text being rendered.
Powerline ships a fontconfig snippet that makes its symbol font the preferred monospace:
<alias><family>monospace</family><prefer><family>PowerlineSymbols</family></prefer></alias>
PowerlineSymbols contains only the powerline glyphs — no letters, no digits:
$ fc-query --format="%{charset}" /usr/share/fonts/OTF/PowerlineSymbols.otf
2588 e0a0-e0a2 e0b0-e0b3
So every character in an ordinary text file falls to .notdef.
Terminals are unaffected because they fall through to another font per glyph. texttopdf resolves once, for the document.
Reproduction
Install powerline-fonts (or any package aliasing monospace to a symbol-only font), then:
CUPS_DATADIR=/usr/share/cups CHARSET=utf-8 \
/usr/lib/cups/filter/texttopdf 1 u t 1 "" < any.txt | pdffonts -
pdffonts shows PowerlineSymbols-Identity-H embedded, and the output prints as boxes.
Suggested fix
Check glyph coverage for the text before committing to a font, and fall back when the resolved font cannot render it — fontconfig can answer this via the font's charset. Anything that avoids embedding a font guaranteed to produce .notdef for the entire document would do.
Environment
cups 2.4.19, libcupsfilters from cups-filters 2.0.1, fontconfig 2.17, Arch/CachyOS.
I have reported the packaging side separately, since shipping that alias enabled by default is arguably also wrong — but a filter that embeds a font which cannot render the document seems worth fixing regardless of what any given package does.
Contributor 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.
Research direction
Start at cfFilterTextToPDF, the shared texttopdf filter described in the report, and reproduce the issue with the provided CUPS_DATADIR, CHARSET, and pdffonts command. Trace how monospace is resolved and embedded for the document, then verify that symbol-only fonts do not produce an all-.notdef PDF and that ordinary text still renders correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100