Skip to content

Text rendering modes 4-7 paint nothing and never clip #137

Open

Description

@tannevaled

paintGlyph (text.go:243-253) paints a glyph only when the text rendering mode is fill (0), stroke (1) or fill-then-stroke (2). Modes 4, 5 and 6 (fill, stroke, or fill-then-stroke, each also adding the glyph to the clip) are not painted at all. Mode 7 (add to clip only) adds nothing to the clip either.

PDF 32000-1:2008 §9.3.6, Table 106: modes 4–6 paint exactly like 0–2, and also add the glyph outlines to the clipping path, which takes effect at the next ET. Mode 7 paints nothing and only adds to the clip.

Effect

  • Text set in modes 4–6 is invisible on the rendered page, where poppler and MuPDF show it.
  • Anything drawn after ET that should be clipped to the glyph shapes (the "image seen through the letters" effect, modes 4–7) is drawn unclipped.

Repro

A content stream with BT /F1 48 Tf 4 Tr 72 700 Td (Clip) Tj ET renders no ink, while 0 Tr renders the word.

Found while designing PDF to SVG output for go-pdfkit/bentogap (the SVG device will need the same mode handling).

Prior art: priorart "blend mode BM" at 2026-11-22 11:17 CET reported prior art; checked: priorart: #3 Draw text, #18, clip PRs #14/#62/#66/#79 - none handles Tr 4-7; text.go defines modes 0-3 only

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions