Repository navigation
Draw no stroke for an empty or missing /C, as Acrobat does - #104
Merged
Merged
Conversation
A square, circle, polygon, line, polyline or ink whose /C is the empty array (ISO 32000's "no colour; transparent") or left out now draws no stroke. The generator used to stroke both in black whenever the border width was above 0. Checked against Acrobat with annotations that have no appearance stream: - No stroke: the fill alone, still inset half the border width, where the stroke's middle would be. A line keeps only its filled closed endings, sized by its width; ink paints nothing but keeps its points (and /Rect). - /BS /W 0 (or /Border [0 0 0]) on a line, polyline or ink is a hairline (0 w, the thinnest line the device draws), with the endings a 1 pt line has. Ink at width 0 used to get no appearance and a line a 1 pt one. A square, circle or polygon at width 0 still has no outline. - A dimension line with no stroke colour draws its filled endings and caption, without segments or leaders. Every stroke that has a colour is written byte for byte as before. EPDFAnnot_SetNoColor() writes a colour entry as the empty array. EPDFAnnot_ClearColor() removes the entry instead, which Preview draws in black for a stroke; an empty /C is no stroke in Acrobat and Preview alike. Tests: the empty array written and read back as no colour; no stroke for a square, circle and polygon with /C left out and empty, the fill inset; a line's filled endings only; hairlines at width 0 for a line, polyline and ink; ink with no colour paints nothing and keeps its /Rect; the C API list; layer-mode writers. Eight stroke-geometry tests and the measurement tests' line helper built shapes without a /C and now set one. On macOS the full embedder suite and the pixel tests fail the same tests as main.
roanutil
pushed a commit
to roanutil/embed-pdf-viewer
that referenced
this pull request
Nov 4, 2026
A square, circle, polygon, polyline, line or ink annotation takes `color: null` for no stroke and keeps its `strokeWidth`. The engine writes it as `/C []`, the empty colour ISO 32000 defines as no colour, and reads an empty or missing `/C` as `null`: that's how Acrobat draws both (checked with a grid of shapes without appearance streams). A missing `/C` used to read as red. - Engine: the stroked kinds' `color` is nullable; the reader drops its red default; the writer uses the runtime's new `EPDFAnnot_SetNoColor`. `runNoStrokeConformance` checks reads, writes, creates and pixels on both engines, from the Acrobat grid's cases. - Viewer: `Style.color` may be `null` and the scene paints no stroke for it. A line, polyline or ink at width 0 is a hairline (`Paint.hairline`, one pixel at any zoom) with a 1 pt line's endings, as the runtime and Acrobat draw it; it drew nothing before. - Style panel: a colour property's `allowsNone` offers "none". On a shape's or line's stroke and fill, a text box's background, a redaction's fill and a form field's border and background; never on ink or markup, which would just vanish. Tool defaults take `color: null` too. - Docs: "Without a line" on the shapes page, the style section and the style-panel property table; the style-panel samples use `allowsNone`. Synced to both sites. - Contract and SDK: `color` is nullable on the six kinds (`pnpm api:sync`). API snapshots, changesets. Runtime: embedpdf/runtime#104 (`EPDFAnnot_SetNoColor`), in the pinned f2dd40897.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A square, circle, polygon, line, polyline or ink whose
/Cis the empty array (ISO 32000's "no colour; transparent") or left out now draws no stroke. The appearance generator used to stroke both in black whenever the border width was above 0. That's what lets the engine offercolor: null, a shape without a line, written as/C [].Checked in Acrobat against a grid of shapes with no appearance stream, one row per stroke case:
/C []and for/Cleft out alike. The fill stays inset half the border width, where the stroke's middle would be. A line keeps only its filled closed endings, sized by its width. Ink paints nothing but keeps its points and/Rect./BS /W 0or/Border [0 0 0]): a line, polyline or ink is a hairline (0 w, the thinnest line the device draws), with the endings a 1 pt line has. Ink at width 0 used to get no appearance at all, and a line a 1 pt one. A square, circle or polygon at width 0 still has no outline.Every stroke that has a colour is written byte for byte as before.
EPDFAnnot_SetNoColor()writes a colour entry as the empty array.EPDFAnnot_ClearColor()removes the entry instead, and Preview draws a stroke without/Cin black; an empty/Cis no stroke in Acrobat and Preview alike.Tests
/Cleft out and empty, the fill inset half the width./Rect./C; they now set one, so their output is the same as before.On macOS, the full embedder suite and the pixel tests fail the same tests as main (12 embedder, 51 pixel goldens). Linux CI hasn't run yet.
The engine side (
color: nullon the stroked kinds, the reader, the viewer's style panel, docs and SDKs) is in embedpdf/embed-pdf-viewerfeature/no-stroke. It needs this released and pinned.