Skip to content

PDF stage 4.2: strokes & line style#560

Merged
andiwand merged 2 commits into
mainfrom
pdf-stage-4.2-strokes
Jun 25, 2026
Merged

PDF stage 4.2: strokes & line style#560
andiwand merged 2 commits into
mainfrom
pdf-stage-4.2-strokes

Conversation

@andiwand

@andiwand andiwand commented Jun 24, 2026

Copy link
Copy Markdown
Member

🤖 Generated with Claude Code

Stacked on #559 (stage 4.1). Completes the path-painting vocabulary: stroked paths and stroke styling.

What this does

  • GraphicsState: a real dash pattern (d → array + phase, replacing the int placeholder) and spec-correct initial values (line width 1, miter limit 10). When a path is painted, stroke width and dash lengths are folded by the CTM area scale (sqrt|det|) so they share the geometry's user space (an anisotropic pen — which SVG can't express — is approximated).
  • HTML emits stroked <path>s: stroke color, stroke-width (0 → hairline), stroke-linecap (round/square), stroke-linejoin (round/bevel), stroke-miterlimit, stroke-dasharray/-dashoffset. Fill+stroke (B/b) emit both.
  • Cleanup: removes the leftover stdout debug in pdf_graphics_state.cpp — dash is implemented; the SC/SCN named/ICC/Separation/Pattern color ops become explicit stage-4.4 no-ops instead of per-operator stdout spam. Drops <iostream>.

Tests / verification

New stroke IR tests (line params, dash parse, CTM scaling of width & dash, solid reset). End-to-end:

<path d="M 20 180 L 180 20" fill="none" stroke="rgb(255,0,0)" stroke-width="5"
      stroke-linecap="round" stroke-miterlimit="10" stroke-dasharray="6,3" stroke-dashoffset="2"/>

and the Infineon datasheet now renders 672 strokes (11 dashed). PDF suite green (128).

Reviewers: as with 4.1, the reference-output fixtures need regenerating.

@andiwand andiwand force-pushed the pdf-stage-4.1-svg-fills branch from 27fb785 to f200ad3 Compare June 25, 2026 09:57
Base automatically changed from pdf-stage-4.1-svg-fills to main June 25, 2026 10:32
Render stroked paths and stroke styling, completing the path-painting
vocabulary started in 4.0/4.1.

- `GraphicsState`: real dash pattern (`d` -> array + phase, replacing the int
  placeholder), and spec-correct initial values (line width 1, miter limit
  10). Stroke width and dash lengths are folded by the CTM area scale
  (sqrt|det|) when snapshotted, so they share the geometry's user space; an
  anisotropic pen is approximated (SVG can't express one).
- `PathElement` carries the dash array/phase; the HTML layer emits stroked
  `<path>`s — stroke color, `stroke-width` (0 -> hairline), `stroke-linecap`
  (1/2 round/square), `stroke-linejoin` (1/2 round/bevel), `stroke-miterlimit`,
  `stroke-dasharray`/`-dashoffset`. Fill+stroke (`B`/`b`) emit both.
- Cleanup: the leftover stdout debug in pdf_graphics_state.cpp is gone — dash
  is implemented; the SC/SCN named/ICC/Separation/Pattern color ops are now
  explicit stage-4.4 no-ops instead of stdout spam. Drops <iostream>.

Adds stroke-parameter tests (line params, dash parse, CTM scaling of width
and dash, solid reset). Verified end-to-end: a synthetic dashed stroke and
the Infineon datasheet (672 strokes, 11 dashed). PDF suite green (128).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011jPrCgocCTnKhMi3k6VBjU
@andiwand andiwand force-pushed the pdf-stage-4.2-strokes branch from 3b88520 to 046a759 Compare June 25, 2026 10:49
@andiwand andiwand merged commit 943c1d7 into main Jun 25, 2026
9 checks passed
@andiwand andiwand deleted the pdf-stage-4.2-strokes branch June 25, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant