Skip to content

fix: resolve 8 reported bugs (PDF clipping/even-odd/shading/dash/stroke, TIFF LZW, PPTX table growth/slide-number) - #43

Merged
Malcolmnixon merged 21 commits into
mainfrom
fix/docpilot-upstream-issues
Oct 9, 2026
Merged

Malcolmnixon merged 21 commits into
mainfrom
fix/docpilot-upstream-issues

Conversation

@Malcolmnixon

@Malcolmnixon Malcolmnixon commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Pull Request

Description

Fixes 8 bugs reported by downstream projects while adopting DemaConsulting.CanvasNet 0.1.0-beta.10:

PDF (DemaConsulting.CanvasNet.Pdf)

  1. W/W* clipping-path operators were parsed but never enforced, so content outside the current
    clip was drawn (visible as stray frames/boxes on WeasyPrint-generated PDFs). Implemented a
    ClipMask abstraction and enforced it at every fill/stroke/image/glyph paint site.
  2. Even-odd fills (f*) with 4+ subpaths on a single scanline (e.g. CSS border: double) resolved
    as nonzero because ScanlineRasterizer's even-odd fold didn't handle rows with 2+ mid-row
    toggles. Rows are now split into exact sub-intervals and height-weighted-averaged.
  3. The sh (shading) operator was entirely unimplemented, so shading/gradient fills silently
    rendered solid black. Implemented sh name, reusing existing /PatternType 2 resolution logic.
  4. Dash arrays with a zero-length entry (e.g. [dash gap dot gap]) dropped the dot, rendering
    dash-dot as plain dashes. DashSplitter now emits exactly one zero-length on-interval per
    repetition instead of skipping it.
  5. Hairline/sub-pixel stroke widths were clamped to a full device pixel, rendering heavier than
    PDFium. Split the clamp into a literal-zero-width tolerance (still clamps) vs. a much smaller
    positive-width floor, so genuinely thin strokes anti-alias naturally.

TIFF (DemaConsulting.CanvasNet)

  1. TiffCodec.Save with LZW compression wrote data that couldn't be read back (by this library or
    Pillow) above a certain image size. The encoder was using the decoder's "early change" code-width
    thresholds by mistake; corrected to the plain thresholds TIFF's LZW encoder requires.

PPTX (DemaConsulting.CanvasNet.Pptx)

  1. Table rows kept their stored <a:tr h> height even when cell text wrapped to more lines than fit,
    causing overlapping text. Rows now grow to fit wrapped text, with row-span shortfall distributed
    onto the spanned rows.
  2. Slide-number fields (<a:fld type="slidenum">) rendered their cached placeholder text (‹#›)
    instead of the actual slide number. Fields are now substituted with the real 1-based slide number
    at render time.

Also included in this branch

  • README.md cleanup: trimmed multi-line Features bullets to one line each, consolidated the
    per-package Installation section, and reduced Usage to 3 representative examples with a pointer to
    the existing, more granular docs/user_guide/introduction.md Examples section (no content lost).
  • ApiMark-generated API doc review: spawned sub-agents to read only the generated API docs (no
    source) across all 6 packages and quiz themselves on key usage patterns, simulating a coding agent
    consuming these docs unassisted. Fixed the resulting defects: dangling cross-references to
    private/internal members, a garbled sentence, missing constructor docs, stale/contradictory
    narrative in PdfDocument and SvgCodec, and a broken Charts cross-reference.
  • Formal/change-review of all 14 review-sets touched by this branch, which caught and fixed a real
    ArgumentOutOfRangeException in GrowRowHeightsToFitText for malformed rowSpan values, plus
    several documentation-only gaps (stale verification test counts, missing requirement links, a
    missing ClipMask/slide-number mention in the design/decomposition docs).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

No GitHub issues were filed for these; they were reported directly by a downstream consumer and fixed in-place per maintainer direction.

Pre-Submission Checklist

Build and Test

  • Code builds successfully and all tests pass: pwsh ./build.ps1 (11,400/11,400 passing)
  • Code produces zero warnings

Code Quality

  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

  • All linters pass: pwsh ./lint.ps1 (exit 0)

Testing

  • Added unit tests for new functionality
  • Updated existing tests if behavior changed
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
  • Updated docs/ documentation (if applicable)
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)

Additional Notes

Formal/change-review (dotnet reqstream --lint, dotnet reviewmark --lint, dotnet sysml2tools lint)
all pass cleanly. All 15 commits are scoped and serial (one bug/task per commit); see commit log for
full detail.

Malcolm Nixon and others added 16 commits October 8, 2026 19:30
PdfDocument.Render previously ignored the content-stream clipping
operators W (nonzero winding) and W* (even-odd), silently falling
through the default case in DispatchOperator. This caused geometry
that a real PDF viewer (e.g. PDFium) clips away to instead be painted
in full, producing visible artifacts such as stray frames around page
content and stray boxes next to TOC entries in WeasyPrint-produced
PDFs.

W/W* now defer clip application until the next path-painting operator
executes (e.g. n, f, S), per spec: the operator still paints according
to its own semantics, and the current path becomes the new clip,
intersected with (never replacing) any previously active clip. W uses
nonzero winding and W* uses even-odd specifically to interpret the
path for clipping purposes, independent of the painting operator's own
fill rule.

Adds a new internal ClipMask type (Drawing layer): a per-pixel
antialiased coverage mask bound to the surface's pixel extent, built
by rasterizing a path with a given fill rule via ScanlineRasterizer,
and combined with a prior clip via elementwise coverage intersection.
New internal clip-aware overloads are threaded through
PathFiller/ScanlineRasterizer fill paths without changing any existing
public API signatures.

PdfDocument.GraphicsState now carries the active Clip, cloned/restored
through q/Q so a clip set inside a q...Q block cannot leak outside it.
The clip is enforced for path fill/stroke, image Do compositing, and
glyph-fill text painting.

Adds ClipMaskTests, additional PathFillerTests, and new PdfDocument
clipping tests covering: W n clip + fill, clip scoping via q/Q, W*
even-odd clip semantics, nested clip intersection, clip + image Do,
and clip + glyph fill.

Updates docs/reqstream, docs/design, docs/verification, sysml2 model,
and .reviewmark.yaml companion artifacts for traceability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…lineRasterizer

The per-row cell-based signed area/cover accumulation in CoverageSweep computes,
per column, a single scalar approximating the row-height-weighted integral of the
winding number, then folds it via magnitude % 2 for FillRule.EvenOdd. This fold
is only valid when at most one edge toggles within a device-pixel row for a given
column; it is mathematically wrong whenever two or more edges' start/end y
boundaries land strictly inside the same row for the same column, since
fold(integral(w dy)) != integral(parity(w(y)) dy) once w takes values above 1
within the row.

This caused WeasyPrint's CSS �order: double (and any even-odd fill with nested
same-x-range subpaths whose y-boundaries land within one device pixel row) to
rasterize as a single solid bar instead of two separate lines, confirmed via the
reported content stream:

  0.6 0.6 0.6 rg 96 65 624 930 re 96 61.67 624 934 re 96 63.33 624 932 re
  96 60 624 936 re f*

Fix: detect, per row, whether two or more edges have Y0/Y1 landing strictly
inside the row (mid-row breakpoints). For FillRule.NonZero, and for EvenOdd rows
with fewer than two breakpoints, the original single-pass accumulation and
ResolveCoverage fold are used completely unchanged (verified bit-for-bit via the
full pre-existing test suite). For EvenOdd rows with two or more breakpoints, the
row is split into exact sub-intervals at each breakpoint y; each RowEdge's affine
x(y) mapping is re-interpolated per sub-interval (exact for slanted edges, not
just axis-aligned ones), each sub-interval is resolved via the same unmodified
fold, and the sub-interval results are combined via a height-weighted average to
produce the final per-column coverage.

This only changes asymptotic cost for the rare multi-breakpoint-per-row EvenOdd
case (O(edges + columns * breakpoints) instead of O(edges + columns)); the common
single-toggle-per-row case and all NonZero fills retain their original cost and
output.

Added regression tests:
- ScanlineRasterizerTests: nested-rectangles-in-one-row counter-example (~0.334
  coverage), single-boundary-per-row even-odd case unchanged, slanted-edge
  multi-sub-row-toggle case, and explicit NonZero-unaffected coverage.
- PdfSystemIntegrationTests: PDF-level regression reproducing the literal
  bug-report content stream via a new fixture, asserting the gap between the two
  lines is not fully opaque.

Updated docs/design, docs/verification, and docs/reqstream for
canvas-net/drawing/path-filler to describe the corrected algorithm and new tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-rendering

The content-stream dispatcher's default branch silently skipped the `sh`
operator (PDF 32000-1 section 8.7.4.2), which paints a shading directly onto
the current clipping path without a path or Pattern color space. Producers
(e.g. Visio PDF export) that draw a black fallback shape and then paint a
gradient over it via `sh` therefore kept showing the black fallback with no
exception, matching the reported "gradient drawn as solid black" symptom.

Add `case "sh"` dispatch plus `OpPaintShading`, extract the existing
`/ShadingType`/`/ColorSpace`/`/Function`/`/Domain`/`/Coords`/`/BBox`
resolution shared by the working scn+Pattern path into
`ResolveShadingDescriptor` (BuildShadingPattern is now a thin wrapper over
it, behavior-preserving), and reuse the existing clip-mask-aware
PathFiller.Fill overload from the W/W* clipping feature so sh composes with
an active clip. When no clip is active, bound the paint region using the
shading's own /BBox (or the full surface, further bounded by PathFiller's
surface-bounds intersection) instead of ever painting unboundedly. Unsupported
/ShadingType or color space values reached via sh now throw the same
UnsupportedImageFeatureException the scn+Pattern path already throws, so the
previously-silent case is now reported.

Add unit tests for direct axial/radial sh painting, clip composition, BBox
fallback bounding, and unsupported-shading-type/undeclared-name failures, plus
a system-integration reproduction of the bug report (black rectangle fill
followed by an sh gradient overlay) proving the gradient is now visible.

Update design docs, reqstream requirements, and verification docs/sysml2
model to add the new CanvasNetPdf-PdfDocument-ShadingOperator requirement and
its traceability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
DashSplitter.AdvanceDash previously skipped over zero-length dash-pattern
entries entirely while advancing, including zero-length 'on' entries. This
is the standard technique producers (PDF/SVG/CSS, e.g. WeasyPrint) use to
render a dash-dot border: a degenerate zero-length dash combined with a
round or square line cap renders as a dot. Because the zero-length 'on'
entry was skipped rather than emitted, dash-dot patterns such as
'[D G 0 G] 0 d' rendered as plain dashes with the dot missing entirely.

AdvanceDash is collapsed to a single pattern-entry step, and
BuildOnIntervals now emits exactly one zero-length on-interval per pattern
repetition when it lands on a zero-length 'on' entry (bounded by the
existing MaxOnIntervalCount safety cap). EstimatesExceedBudget's pre-flight
formulas are corrected to account for zero-length 'on' entries now costing
iterations/intervals, while remaining algebraically identical to the
previous formulas for zero-free patterns (no regression). Degenerate
all-zero-length patterns (e.g. [0 0]) continue to be filtered upstream in
Split via GetPatternLength <= 0, so they still safely fall back to a solid
stroke with bounded, unchanged behavior. All XML-doc and inline comments
describing the old skip-all-zero-length behavior were updated to describe
the new behavior.

Adds unit tests at the DashSplitter level proving a [2,2,0,2]-style
dash-dot pattern now yields dash and dot on-intervals at the expected
positions across multiple pattern repetitions, plus regression tests
confirming zero-length 'off' entries remain invisible and degenerate
all-zero-length patterns still terminate safely with bounded output. Adds
a PDF content-stream integration test reproducing a dash-dot 'd' operator
array with a zero entry, asserting the rendered stroke now contains a
visible dot pixel distinct from and isolated by the surrounding dash gaps.

Updates design, verification, and requirement-stream documentation for the
PathStroker unit to reflect the corrected cost-model formulas and the new
dot-emission behavior, per this repository's architecture-model and
requirements traceability standards.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…hange rule

TiffCodec.Save with TiffCompression.Lzw produced files that this library's
own decoder and third-party readers (Pillow/libtiff) both rejected with
"Invalid TIFF LZW code sequence" / "Using code not yet in table" once the
LZW table grew past 510 entries, because EncodeLzw widened its output code
size one table entry too early (nextCode is 511 or 1023 or 2047).

TIFF 6.0 Section 13 mandates an asymmetric "early change" convention: only
the LZW decoder widens its code size one entry earlier than classic LZW,
to compensate for the decoder's inherent one-iteration lag behind the
encoder when registering new table entries. The encoder must use the
plain/unadjusted thresholds. DecodeLzw/AddLzwTableEntry already implemented
the correct early-decode thresholds (511/1023/2047); only EncodeLzw was
wrong and needed to move to 512/1024/2048.

Verified against libtiff's tif_lzw.c (the reference implementation Pillow
delegates to) and confirmed empirically: bidirectional, pixel-exact
round-trips between this library and Pillow 12.1.1 now succeed across all
three code-width boundaries (510/1022/2046 table entries).

- Fix EncodeLzw's code-width bump thresholds (511/1023/2047 -> 512/1024/2048)
- Leave DecodeLzw/AddLzwTableEntry thresholds unchanged (already correct)
- Document the TIFF "early change" asymmetry in XML doc remarks on
  EncodeLzw, DecodeLzw, and AddLzwTableEntry, citing TIFF 6.0 Section 13
- Fix TestEncodeLzw's matching thresholds in TiffCodecTests.cs
- Add TiffCodec_SaveThenLoad_LzwLargeVariedImage_RoundTripsAcrossAllCodeWidthBoundaries,
  a deterministic 200x200 high-entropy round-trip test that crosses all
  three LZW code-width boundaries and fails against the pre-fix encoder
- Update design/verification/reqstream docs for the Tiff Codec unit

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Table rows previously always rendered at the stored a:tr h= EMU height,
even when a cell's text wrapped to more lines than that height could
fit, causing neighboring rows' text to overlap. Row heights now grow
(never shrink) to fit each cell's actual wrapped text content.

- Extract ResolveTextLayout's wrap/measure steps into a new
  ResolveWrappedLines helper (behavior-preserving) and add a
  MeasureRequiredTextHeightEmu entry point in
  PptxDocument.TextLayout.cs for measuring a cell's required text
  height at its resolved width.
- Add GrowRowHeightsToFitText in PptxDocument.Tables.cs: single-row
  cells grow their row to max(storedHeightEmu, requiredTextHeightEmu);
  row-spanning cells apply any shortfall between the stored span
  total and the required merged-cell height onto the last spanned
  row. ResolveCellRects/WalkResolvedCells consistently use the
  resulting effective heights for all row Y-offsets and cell rects.
- Update PptxTable.cs XML docs to describe min/effective height
  semantics instead of a fixed, never-growing height.
- Add tests covering growth, regression-safety when the stored height
  is already sufficient, row-span shortfall distribution, and
  opt-in-only default behavior when optional measurement parameters
  are omitted.
- Update design, verification, requirements (reqstream), and SysML2
  model docs to reflect the new row-height growth behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fix <a:fld type="slidenum"> fields rendering PowerPoint's cached
authoring-time placeholder text (e.g. the literal guillemet glyphs
<#>) on every slide, instead of showing each slide's real 1-based
slide number as PowerPoint itself does on screen/export.

- PptxTextBody.cs: add nullable FieldType to PptxRunItem to capture
  the <a:fld> type attribute instead of discarding it.
- PptxDocument.Text.cs: ParseParagraph now captures the field type;
  add pure SubstituteSlideNumberField(textBody, slideNumber) that
  replaces only slidenum-typed run text (case-insensitive) with the
  plain decimal slide number, rebuilt via primary constructors to
  avoid stale Runs-accessor pitfalls. Scope the long-standing
  'no live engine to recompute fields' doc comment to the field
  types that still legitimately fall back to cached text (e.g.
  datetime variants), since slidenum is now computed internally.
- PptxDocument.Render.cs: thread the existing 1-based slide index
  through Render -> RenderNode -> RenderShape and call
  SubstituteSlideNumberField on each shape's text body before
  layout/measurement.
- Tests: parse-level FieldType capture tests, direct
  SubstituteSlideNumberField unit tests (case-insensitivity,
  datetime/plain-run non-regression, Runs-accessor regression), and
  end-to-end multi-slide render tests proving per-slide substitution
  (slide 1 -> "1", slide 2 of 2 -> "2") with datetime/plain-run
  fields unaffected.
- Docs: new reqstream requirement, design 'Phase 2 Follow-Up'
  section, and verification section for slide-number field
  substitution; .cspell.yaml: add 'Xmls' for the new design prose.

This is the last of 8 upstream CanvasNet.Pptx issues fixed on this
branch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Features: one line per bullet, moving detail to the user guide/API docs
- Installation: single generic command plus a package table instead of
  per-package dotnet/PMC duplicate blocks
- Usage: reduced to 3 representative examples (codec round-trip, PDF
  render, vector path fill); all removed examples were already present
  (or more granular) in docs/user_guide/introduction.md's Examples
  section, which is now called out as the canonical place to find them

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
GrowRowHeightsToFitText computed lastSpannedRowIndex = rowIndex + rowSpan - 1
without validating it against the table's actual row count, so a malformed
PPTX declaring a rowSpan extending past the end of the table threw
ArgumentOutOfRangeException while resolving cell rects. Clamp the index to
effectiveHeightsEmu.Count - 1, mirroring the existing SumConsecutive clamp
pattern used elsewhere in the same file, so the shortfall is added onto the
last actual row instead of indexing out of bounds.

Found during the formal change-review of canvas-net-pptx/pptx-document for
branch fix/docpilot-upstream-issues.

Adds a regression test and documents the clamp behavior in the design doc.
PdfDocument.cs's and NamespaceDoc.cs's 'documented scope boundaries' remarks
still listed the sh (shading) operator and generic path clipping (W/W*) as
unsupported, left stale after commits 506dbf4 (W/W* clipping) and 69ee60f
(sh shading) implemented both without updating these two files' doc comments
(every other dispatch comment, e.g. in ContentStream.cs, was correctly
updated at the time).

Also clarifies PdfDocument.Patterns.Shading.cs's BuildShadingGradient remarks:
OpPaintShading already honors the current clip path via ClipMask, so the
prior remark's 'clip path is not honored' framing was both stale and
conflated with a separate, still-unaddressed concept (clipping a gradient to
its own shading-geometry bounds for an exact /Extend false approximation,
currently approximated via GradientSpread.Pad only). Mesh shadings
(ShadingType 4-7) remain genuinely unsupported and are still documented as
such.

Found during the formal change-review of canvas-net-pdf/pdf-document for
branch fix/docpilot-upstream-issues.
The verification doc claimed 70 test methods (65 in TiffCodecTests.cs + 5 in
TiffFixtureTests.cs); the actual counts are 62 and 5 (67 total), verified by
counting public test methods in both files. Left stale by prior edits to
TiffCodecTests.cs.

Found during the formal change-review of canvas-net/codecs/tiff-codec for
branch fix/docpilot-upstream-issues.
…comments

Add the new unit requirement
CanvasNet-Drawing-PathFiller-ScanlineEvenOddMultiToggleRow (introduced by
this branch's even-odd multi-toggle-row coverage fix, defined in
docs/reqstream/canvas-net/drawing/path-filler.yaml) to the children: list of
the parent subsystem requirement CanvasNet-Drawing-PathFill in
docs/reqstream/canvas-net/drawing.yaml - every sibling Scanline* requirement
was already linked except this one.

Also add Arrange/Act/Assert comments to
PathFiller_Fill_SolidColorWithNullClip_BehavesLikePublicOverload in
PathFillerTests.cs, matching its already-commented sibling test, for
consistency with this branch's new ClipMask-aware fill tests.

Found during the formal change-review of canvas-net/drawing/path-filler for
branch fix/docpilot-upstream-issues.
BuildOnIntervals ended with 'if (!isClosed) { return intervals; } return
intervals;' - both branches returned the identical value, a no-op isClosed
check pre-existing on main (confirmed via diff against main, not introduced
by this branch's dash-dot fix). Collapsed to a single return; isClosed was
otherwise unused within BuildOnIntervals once the dead branch was removed,
so the now-unused parameter was also removed from the method and its sole
call site (flagged by the build's own S1172 unused-parameter analyzer).

Found during the formal change-review of canvas-net/drawing/path-stroker for
branch fix/docpilot-upstream-issues.
docs/design/introduction.md's Drawing subsystem Scope/Software-Structure
prose and Folder Layout tree didn't mention the internal ClipMask
clip-coverage helper added by this branch's clip-mask-aware fill fix.

The CanvasNetPptx sysml model narratives (canvas-net-pptx.sysml and
canvas-net-pptx/pptx-document.sysml) already described the table
row-height-growth fix but were never updated for the subsequent
slide-number field-substitution fix (SubstituteSlideNumberField); both
narratives now describe it alongside the row-height-growth entry.

Found during the formal change-review of the Decomposition review-set for
branch fix/docpilot-upstream-issues. Verified with 'dotnet sysml2tools lint'.
Copilot AI lite review requested due to automatic review settings October 9, 2026 16:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

5 open findings
What changed in this PR

This PR fixes PDF clipping/shading/stroke behavior, TIFF LZW encoding, PPTX table sizing and slide-number rendering, plus associated tests and documentation.

Changes:

  • Added clipping, shading, even-odd, dash, and stroke fixes.
  • Corrected TIFF LZW width transitions.
  • Added PPTX row growth and slide-number substitution.
File Description
test/​DemaConsulting.CanvasNet.Tests/​Drawing/​ScanlineRasterizerTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Tests/​Drawing/​PathFillerTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Tests/​Drawing/​DashSplitterTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Tests/​Drawing/​ClipMaskTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Tests/​Codecs/​TiffCodecTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Tests/​Canvas/​SurfaceTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Pptx.Tests/​PptxTextTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Pptx.Tests/​PptxTablesTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Pdf.Tests/​PdfSystemIntegrationTests.cs Updated as part of this pull request.
test/​DemaConsulting.CanvasNet.Pdf.Tests/​PdfFixtures/​README.md Updated as part of this pull request.
src/​DemaConsulting.CanvasNet/​Drawing/​PathFiller.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet/​Drawing/​NamespaceDoc.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet/​Drawing/​GradientEvaluator.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet/​Drawing/​ClipMask.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet/​Codecs/​Tiff/​TiffCodec.Compression.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet/​Canvas/​Surface.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxUnsupportedFeatureException.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxTheme.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxResolvedPaint.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxRenderOptions.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxPageInfo.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxDocument.Theme.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxDocument.Render.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxDocument.Paint.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxDocument.Masters.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxDocument.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxDocument.Connects.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxDocument.Arrowheads.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxConnectorEndpoints.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxColorPalette.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​VsdxArrowhead.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Vsdx/​NamespaceDoc.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Svg/​SvgCodec.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxUnsupportedFeatureException.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxTextBody.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxTable.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxRenderOptions.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxPresetGeometry.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.TextLayout.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Text.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.TableStyles.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Paint.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Images.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Geometry.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Connectors.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Charts.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Background.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pdf/​PdfDocument.Text.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pdf/​PdfDocument.Images.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pdf/​PdfDocument.GraphicsState.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pdf/​PdfDocument.ContentStream.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Pdf/​NamespaceDoc.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Charts/​OpenXml/​ChartUnsupportedFeatureException.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Charts/​ChartRenderOptions.cs Updated as part of this pull request.
src/​DemaConsulting.CanvasNet.Charts/​ChartBuilder.cs Updated as part of this pull request.
docs/​verification/​canvas-net/​drawing/​path-stroker.md Updated as part of this pull request.
docs/​verification/​canvas-net/​drawing/​path-filler.md Updated as part of this pull request.
docs/​verification/​canvas-net/​codecs/​tiff-codec.md Updated as part of this pull request.
docs/​verification/​canvas-net-pptx/​pptx-document.md Updated as part of this pull request.
docs/​verification/​canvas-net-pdf/​pdf-document.md Updated as part of this pull request.
docs/​sysml2/​model/​canvas-net/​drawing/​path-filler.sysml Updated as part of this pull request.
docs/​sysml2/​model/​canvas-net-pptx.sysml Updated as part of this pull request.
docs/​sysml2/​model/​canvas-net-pdf/​pdf-document.sysml Updated as part of this pull request.
docs/​reqstream/​canvas-net/​drawing/​path-stroker.yaml Updated as part of this pull request.
docs/​reqstream/​canvas-net/​drawing/​path-filler.yaml Updated as part of this pull request.
docs/​reqstream/​canvas-net/​drawing.yaml Updated as part of this pull request.
docs/​reqstream/​canvas-net/​codecs/​tiff-codec.yaml Updated as part of this pull request.
docs/​reqstream/​canvas-net-pptx/​pptx-document.yaml Updated as part of this pull request.
docs/​reqstream/​canvas-net-pdf/​pdf-document.yaml Updated as part of this pull request.
docs/​design/​introduction.md Updated as part of this pull request.
docs/​design/​canvas-net/​drawing/​path-stroker.md Updated as part of this pull request.
docs/​design/​canvas-net/​drawing/​path-filler.md Updated as part of this pull request.
docs/​design/​canvas-net/​drawing.md Updated as part of this pull request.
docs/​design/​canvas-net/​codecs/​tiff-codec.md Updated as part of this pull request.
.reviewmark.yaml Updated as part of this pull request.
.cspell.yaml Updated as part of this pull request.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

…de numbers, docs

- ClipMask/ScanlineRasterizer: restrict the clip coverage buffer to its own
  integer bounding box (with an origin offset) instead of allocating a
  full-page-sized buffer per clip, avoiding large allocations for small clips
  on large pages.
- PdfDocument.Images: use MidpointRounding.AwayFromZero for clipped-image
  alpha rounding, matching Surface's own compositing convention.
- PptxDocument.Tables: fix two integer-overflow bugs in row-height growth
  (SumConsecutive and the row-span shortfall calculation) that could trigger
  on a malformed rowSpan near int.MaxValue; add a regression test.
- PptxDocument.Render/Tables: thread the slide number through table
  rendering so a slidenum field inside a table cell substitutes correctly
  for both row-height measurement and painting, matching the existing
  non-table shape behavior; add regression tests.
- SvgCodec: correct the stale "sixteen implemented filter primitives" count
  to seventeen.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 9, 2026 17:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Moderate findings remain around leading-zero dash handling, size-dependent PPTX cell paints after row growth, field-type normalization, and incomplete regression coverage.

1 open finding
4 resolved since last review
Previously missed (1)

In code that hasn't changed since last review

Medium severity Leading zero-length dash entries suppress expected dots

src/​DemaConsulting.CanvasNet/​Drawing/​DashSplitter.cs:598

A zero-length on entry is still skipped when it is the pattern's first entry (or when the phase lands exactly on it). For example, with [0, 2], remainingInDash starts at zero while dashIndex is 0, but this advances to the off entry before checking parity; the same happens on every cycle, so no dots are emitted. Observe/emit the current zero-length on entry before advancing, and add a leading-zero regression case.

🧠 Review effort: Lite

A dash pattern whose phase lands exactly on a zero-length "on" entry at
path position zero - either the pattern's own first entry (e.g. a
dash-dot pattern starting with the dot, [0, 2]) or any entry the dash
offset normalizes onto exactly - never emitted that entry's dot.

LocatePhaseForward/LocatePhaseBackward intentionally skip forward
through zero-length entries encountered exactly at a target
pattern-space boundary so IsDashOnAtStart (and the zero-length-path
special case) identify the entry genuinely "in effect". But
BuildOnIntervals previously had no way to know such a skip happened at
the very start of the path (position zero), and its own main loop only
detects a zero-length "on" entry when it advances into it internally -
never the one LocatePhase itself consumed before the loop began.

LocatePhase now also reports whether its boundary walk skipped over at
least one even-indexed (on) zero-length entry; BuildOnIntervals surfaces
a single dot at position zero when it did. IsDashOnAtStart ignores the
new value, preserving its existing (separately tested) semantics.

Adds a regression test for a dash pattern beginning with a zero-length
on entry ([0, 2]) over a path spanning several pattern repetitions,
proving the leading dot at x=0 is now emitted alongside the
already-covered mid-pattern dots.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 9, 2026 17:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

One or more issues must be addressed before approval.

3 open findings
Previously missed (1)

In code that hasn't changed since last review

Medium severity Empty field type is not normalized to null

src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Text.cs:156

The PptxRunItem documentation says a field with an empty type attribute produces FieldType == null, but this stores the empty string directly. Normalize an empty attribute to null (or correct the documented contract) so the parser and record documentation agree.

🧠 Review effort: Lite

The "Build Documents" CI job failed ReqStream's --enforce orphan-requirement
check: 4 unit-level requirements added while fixing the DocPilot-reported
issues in this PR were never linked into the system-requirement graph via a
parent requirement's children list, so they were unreachable from any
system/quality-tagged root requirement.

Added each orphan to the children list of its relevant system requirement:
- CanvasNetPdf-PdfDocument-ClippingPath under CanvasNetPdf-ContentStreamInterpreter
- CanvasNetPdf-PdfDocument-ShadingOperator under CanvasNetPdf-PatternFills
- CanvasNetPptx-PptxDocument-SlideNumberFieldSubstitution under CanvasNetPptx-TextLayoutAndRendering
- CanvasNetPptx-PptxDocument-TableRowHeightGrowth under CanvasNetPptx-TableShapes

Verified locally with `dotnet reqstream --requirements requirements.yaml
--tests "TestResults/**/*.trx" --enforce` that no orphan error remains.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 9, 2026 18:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Moderate findings remain for nested PDF clip state, PPTX paint rebasing, and empty field-type normalization; README and stroke-coverage nits also remain.

3 open findings
Previously missed (2)

In code that hasn't changed since last review

Medium severity Isolate pending clip state across nested streams

src/​DemaConsulting.CanvasNet.Pdf/​PdfDocument.ContentStream.cs:81

This reset only runs when a top-level content stream starts, but recursive ExecuteOperators calls for Form XObjects, Type 3 glyphs, and tiling-pattern cells do not save/reset/restore _pendingClipFillRule. A W/W* left pending in one nested stream can therefore be consumed by a later path paint in the caller (or a caller's pending clip can be consumed inside the nested stream), installing the clip in the wrong graphics-state scope. Keep the pending clip state isolated for every nested content-stream execution, just like the graphics state and resources.

Medium severity Normalize empty FieldType attributes to null

src/​DemaConsulting.CanvasNet.Pptx/​PptxDocument.Text.cs:156

The new XML documentation for PptxRunItem.FieldType promises null for an <a:fld type="">, but this stores string.Empty whenever the attribute is present and empty. Normalize an empty attribute to null here so the parser's documented contract is true and empty fields cannot be mistaken for a populated field type.

🧠 Review effort: Lite

Addresses 3 review findings treated as design issues rather than surface bugs:

1. Isolate _pendingClipFillRule across nested content-stream executions
   (src/DemaConsulting.CanvasNet.Pdf/PdfDocument.{Images,Fonts.Type3,Patterns.Tiling}.cs).
   Form XObjects, Type 3 glyph procedures, and tiling-pattern cells all
   re-enter ExecuteOperators but previously left the outer W/W* pending-clip
   flag live and shared: a path-painting operator inside the nested stream
   (for example the tile cell's own fill) would read/clear the outer's
   still-pending clip and install it onto the nested, throwaway graphics
   state instead - silently discarding the outer clip once the nested
   execution returned. Each nested re-entry point now saves the outer value,
   resets it to null for its own scope, and restores it afterward, exactly
   like it already does for _resources/_gs/_gsStack. Added a regression test
   proving a W-then-pattern-fill path keeps restricting a later, unrelated
   fill to the clip rectangle.

2. Count (not just flag) skipped zero-length "on" dash entries
   (src/DemaConsulting.CanvasNet/Drawing/DashSplitter.cs). The previous fix
   for a leading zero-length dot used a boolean SkippedOnEntry, so a pattern
   with multiple consecutive zero-length "on" entries at the phase boundary
   (for example [0, 0, 0, 2], two distinct dots) only ever emitted one dot
   instead of one per skipped entry. LocatePhase/LocatePhaseForward/
   LocatePhaseBackward now return a SkippedOnEntryCount, and BuildOnIntervals
   emits one (0, 0) interval per skipped entry. Added a regression test for
   [0, 0, 0, 2].

3. Normalize an empty <a:fld type=""> attribute to null
   (src/DemaConsulting.CanvasNet.Pptx/PptxDocument.Text.cs), matching
   PptxRunItem.FieldType's documented contract that an empty attribute is
   equivalent to no attribute - previously stored as string.Empty, which
   could be mistaken for a populated field type by a caller checking only
   for non-null. Added a regression test.

Verified locally: `pwsh ./lint.ps1` (exit 0) and `pwsh ./build.ps1`
(11,421/11,421 tests passed, 6 more than baseline from the new regression
tests). Confirmed test #1 fails without its corresponding fix by temporarily
reverting PdfDocument.Patterns.Tiling.cs and re-running it in isolation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 9, 2026 19:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical dash-budget and additional correctness, performance, and documentation findings remain.

2 open findings
2 resolved since last review

🧠 Review effort: Lite

The leading-zero-length-on-entries loop in DashSplitter.BuildOnIntervals
(added to fix 'Leading zero-length dash entries are dropped') materialized
every entry LocatePhase reported via SkippedOnEntryCount without checking
MaxOnIntervalCount. That count is bounded only by pattern.Count (a single
walk through the caller-supplied dash array), which the ratio-based
pre-flight EstimatesExceedBudget cannot see: a pattern consisting almost
entirely of leading zero-length entries followed by one small positive
entry has a tiny patternLength, so the totalLength/patternLength ratio
stays low even though pattern.Count is enormous. The loop now checks
intervals.Count against MaxOnIntervalCount on every append and bails out
as soon as the cap is hit, exactly like the main loop's own backstops.

Added a regression test that calls BuildOnIntervals directly via
reflection (the public Split API's eventual fallback converges to the
same result either way for a merely-just-over-budget input, masking the
difference) with over forty million leading zero-length entries, and
confirmed it fails without the fix (20,000,002 intervals materialized
instead of stopping at the 10,000,000 cap).

Verified locally: `pwsh ./lint.ps1` (exit 0) and `pwsh ./build.ps1`
(11,424/11,424 tests passed, 3 more than baseline from the new
regression test).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings October 9, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Moderate issues remain in negative dash-offset handling and oversized PPTX grid-span validation.

0 open findings

2 resolved since last review

🧠 Review effort: Lite

@Malcolmnixon
Malcolmnixon merged commit 3de3a04 into main Oct 9, 2026
7 checks passed
@Malcolmnixon
Malcolmnixon deleted the fix/docpilot-upstream-issues branch October 9, 2026 21:00
@Malcolmnixon Malcolmnixon changed the title fix: resolve 8 DocPilot-reported bugs (PDF clipping/even-odd/shading/dash/stroke, TIFF LZW, PPTX table growth/slide-number) fix: resolve 8 reported bugs (PDF clipping/even-odd/shading/dash/stroke, TIFF LZW, PPTX table growth/slide-number) Oct 12, 2026
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.

2 participants