Repository navigation
feat(layout): build Heading and ListItem from runs - #654
Merged
Merged
Conversation
Records the normalised bytes of documents built only through them, on the commit before runs are added, so a later difference shows an existing input's output moved.
A heading could not hold a bold word and a list item could not hold a link, because both took one string in one style. Both now take a sequence of runs, as Paragraph does, and the string constructors build a single run so their output is unchanged. A null run or a run with a null style is refused at the constructor, since these are new members.
A null literal bound to the new runs constructors and threw at construction, where 2.3.3 saved a ListItem and threw from Heading with another parameter name. Lowering the runs constructors' overload priority sends those calls back to the string constructors. Runs now returns a read-only view, and the docs state what a run's link covers, what ListItem.Style styles, and that a run drawing no text is not checked.
This was referenced Nov 21, 2026
Tim81
added a commit
that referenced
this pull request
Nov 21, 2026
Golden pins for embedded-font run-built headings and lists: #654 pinned them before #656 changed every embedded TrueType font program. Re-pinned on the merged result. A qpdf --qdf diff between the two commits shows only #656's deliberate changes: /FontBBox in the font descriptor, the FontFile2 program without cmap and with /Length1, and its /Length; the trailer /ID and offsets follow.
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.
Part of #367
HeadingandListItemtake a sequence ofTextRuns, asParagraphdoes, so a heading can hold a bold word and a list item can hold a link.What changed
new Heading(IEnumerable<TextRun>),Heading.Runs,new ListItem(IEnumerable<TextRun>),ListItem.Runs.Heading.Textis the concatenation of the run texts and is the outline title unlessBookmarkTitleis set.Heading.Styleis the first run's style. In a tagged document the heading is oneHnelement and one marked-content sequence, whatever the number of runs.LinkUri. The annotation covers that run and a space that opens the next run, as in aParagraph(the same behaviour, pinned by a test). On a list item built from runs,ListItem.Stylestyles the marker and the children that set no style of their own, not the item's runs. A string-built item keeps its two annotations (marker and content) when its style has a link.Paragraph; the new constructors still refuse a null style on any run.ArgumentNullException) and a run with a null style (ArgumentException), naming the run's index. An empty sequence is accepted, as an empty string is.Runsreturns a read-only view. The string constructors build one run; documents built through them are byte-identical (pins recorded in the first commit, on the commit before the change).Deliberate output changes
None. No input that saved before changes its output.
Overload resolution
Both run constructors carry
[OverloadResolutionPriority(-1)], sonew Heading(null),new ListItem(null!),default!and(null!, null)keep binding to the string constructors, as on 2.3.3. Arrays, collection expressions,List<TextRun>andTextRun[]bind to the run constructors. Tests compile each null-literal form and assert the string constructor's behaviour, and the existing null-text tests are unchanged from main. The attribute adds no public symbol.Not in this PR
Per-run language (
/Langon a run) needs a marked-content property list or aSpanchild element, which is tagging work.Heading.RunsandListItem.Runssay it is not written.Evidence
Value-level tests (
RunsHeadingListItemTests): oneBDC/EMCpair with/H1, theTfswitch between runs, the outline title bytes, the link/Rectx-range (including the space that opens the next run), the overload binding of null literals and run collections, a read-onlyRuns,Stylefrom the first run, the refusals and their indices, empty sequences. Oracles:qpdf --checkclean,pdftotext -layoutprintsDe Save-methodeand1. Zie Instellingen., veraPDF 1.30.42ucompliant, on a fixture asserted to contain the font switch and the link.Mutations
Each mutant was applied to a detached copy of the head commit and the whole Layout test project run in Release on both TFMs; the same tests failed on both.
OverloadResolutionPriorityremoved fromHeading(IEnumerable<TextRun>)Heading_everyNullLiteralForm_bindsToTheStringConstructor,NullArgument_isRefusedByTheCallThatTookItOverloadResolutionPriorityremoved fromListItem(IEnumerable<TextRun>)ListItem_everyNullLiteralForm_bindsToTheStringConstructor,NullText_isStoredAsAnEmptyString(+ 44 more per TFM, mostly list diagnostics tests)Heading.Stylefrom the last runHeading_style_isTheFirstRunsStyle_notTheLastHeading.Runsreturns the internal listRuns_cannotBeChangedThroughACastListItem.Runsreturns the internal listRuns_cannotBeChangedThroughACastHeading_refusesARunWithANullStyle_namingTheIndex,Heading_refusesANullStyleEvenOnAnEmptyRun,ListItem_refusesANullSequence_aNullRun_andANullStyleListItem_gutterWidening_readsAWordThatContinuesOverARunBoundaryAsOneTextandStyle, not the runsHeading_runs_runsPositionsFollowTheMeasuredWidths,Heading_wordSplitBetweenStyles_drawsNoSpace,LinkRect_coversASpaceThatOpensTheNextRun,EmbeddedRuns_oracles_qpdfPdftotextVeraPdf(+ more)Lists_pinTheBytes,EmbeddedLists_pinTheBytes(+ 30 more per TFM)Gates
Release, oracles required (
REQUIRE_ORACLES,REQUIRE_VERAPDF, veraPDF 1.30.4, qpdf 12.4.2, poppler):VellumPdf.Layout.Tests, net10.0VellumPdf.Layout.Tests, net11.0dotnet build VellumPdf.slnx -c Releasedotnet format --verify-no-changes, clean-room check, roadmap--checkThe two skipped cases are the named-pipe saves in
SaveLifecycleTests, which skipped on this machine.