Skip to content

feat: add underline and strikethrough decoration options - #36

Merged
rsubrama83 merged 2 commits into
mainfrom
feat/underline-options
Oct 7, 2026
Merged

rsubrama83 merged 2 commits into
mainfrom
feat/underline-options

Conversation

@rsubrama83

Copy link
Copy Markdown
Collaborator

Closes #11

What

New text style methods on TextStyle and span descriptors:

Area Methods
Line style DecorationSolid() (default), DecorationDouble(), DecorationDotted(), DecorationDashed(), DecorationWavy()
Color DecorationColor(string), independent of the text color
Thickness DecorationThickness(float), in points
Underline position (sub/superscript) UnderlinePositionAuto() (default), UnderlineAtBaseline(), UnderlineBelowGlyphs()

Line style, color and thickness apply to underline and strikethrough (like CSS text-decoration-*). All properties take part in normal style inheritance.

text.Span("typo").Underline().DecorationWavy().DecorationColor(Colors.Red.Medium);

text.DefaultTextStyle(x => x.Underline().UnderlineAtBaseline());
text.Span("H");
text.Span("2").Subscript();   // underline now in line with "H" and "O"
text.Span("O");

Compatibility

  • Defaults (Solid, Auto, text color, font thickness) reproduce the current output exactly; solid lines still go through the existing rectangle drawing.
  • ICanvas (internal) gets DrawTextDecoration for dotted, dashed and wavy lines (Skia path effects / paths). No public breaking change.

Verification

  • Release build green, 184 unit tests pass (16 new in TextDecorationTests: placement for each position mode, color/thickness/style for underline and strikethrough, inheritance, validation, full PDF generation).
  • New examples TextExamples.DecorationStyles and TextExamples.SuperscriptSubscript_UnderlinePosition rendered and checked visually.

Docs

docs/reference/text.md: new subsections for decoration line options and underline position, updated style table and library defaults. AGENTS.md current focus updated.

🤖 Generated with Claude Code

Decoration lines can now be styled independently of the text:
DecorationColor, DecorationThickness and the line styles
DecorationSolid, DecorationDouble, DecorationDotted, DecorationDashed
and DecorationWavy. They apply to underline and strikethrough.

The underline position of sub- and superscript text is configurable:
UnderlinePositionAuto (default, unchanged behavior), UnderlineAtBaseline
(aligned with surrounding text) and UnderlineBelowGlyphs (directly
below the shifted glyphs).

Closes #11

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1fabi0

1fabi0 commented Oct 7, 2026

Copy link
Copy Markdown
Member

I like this change but for strikthrough such options as Baseline or Glyph level would also be very nice currently only this strikthrough is possible:
image

StrikethroughThroughGlyphs (default, unchanged behavior) draws the line
through the shifted glyphs. StrikethroughAtBaseline draws it at the
position and thickness of normal text, giving one continuous line
across formulas like E=mc².

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rsubrama83

Copy link
Copy Markdown
Collaborator Author

Added in 826b769: StrikethroughAtBaseline() draws the strikethrough at normal-text height and thickness so it runs continuously across sub/superscripts (e.g. E=mc²). StrikethroughThroughGlyphs() stays the default, so existing output is unchanged.

@rsubrama83
rsubrama83 merged commit 6c82b30 into main Oct 7, 2026
1 check passed
@rsubrama83
rsubrama83 deleted the feat/underline-options branch October 7, 2026 13:39
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.

Add more underline Options

2 participants