Skip to content

Underline should be continuous across spacing from tracking#544

Closed
christianrondeau wants to merge 1 commit into
SixLabors:mainfrom
christianrondeau:tracking-underline
Closed

Underline should be continuous across spacing from tracking#544
christianrondeau wants to merge 1 commit into
SixLabors:mainfrom
christianrondeau:tracking-underline

Conversation

@christianrondeau

Copy link
Copy Markdown
Contributor

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes SixLabors/ImageSharp.Drawing#405

The issue being that the underline (decoration) length did not take into account the actual advance, but instead only considered the font's advance.

image

Disclaimer: this code was written using AI (Copilot with Claude Opus 4.8), and reviewed by me.

Note that there is a big difference between Chrome's underline and ImageSharp's, but from my understanding, ImageSharp's the correct one because it's based on the post table metrics, and Chrome ignores it. This PR only solves the tracking issue and does not change the underline behavior in other ways.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84%. Comparing base (18925d5) to head (dc19ff4).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #544   +/-   ##
=====================================
  Coverage     84%     84%           
=====================================
  Files        332     332           
  Lines      24684   24683    -1     
  Branches    3612    3612           
=====================================
+ Hits       20785   20807   +22     
+ Misses      3011    2990   -21     
+ Partials     888     886    -2     
Flag Coverage Δ
unittests 84% <100%> (+<1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JimBobSquarePants

Copy link
Copy Markdown
Member

Thanks for the PR. I’m going to reject this one because my local branch already solves the same issue in a way that fits my newer rendering/decorations architecture better.

The core idea is correct: decoration length should use the laid-out glyph advance, including tracking, so underlines/overlines/strikeouts remain continuous across tracking space. However, this PR is based on the older render path and passes a single-axis float advance through the glyph rendering API.

My local branch already passes the full layout advance as a Vector2, keeps fallback behavior for glyph metric advance, and integrates with a newer skip-ink/decorations enabled pipeline. I may still port the regression tests from this PR, because they cover the right behavior, but I don’t want to merge this implementation as-is.

@christianrondeau

Copy link
Copy Markdown
Contributor Author

Excellent, thanks!

@christianrondeau
christianrondeau deleted the tracking-underline branch July 10, 2026 15:52
@olivierbelzile

Copy link
Copy Markdown

Hi 👋 — sorry for commenting on a closed PR, but I wanted to flag something I just noticed. This implementation draws a continuous underline under every characters where in Chrome, the underline is not drawn beneath characters that have a descender extending below the baseline (e.g. g, j, p, q, y).
I've attached a screenshot to illustrate the difference. Just wanted to make sure it was on your radar.

Thanks for your work on this! 🙏

underline

@JimBobSquarePants

JimBobSquarePants commented Jul 13, 2026

Copy link
Copy Markdown
Member

See above.

integrates with a newer skip-ink/decorations enabled pipeline

That new behaviour (enabled by default) will match chrome etc. I’ve got it working locally cannot release it without a matching Drawing release which I’m still working on. Not long though!

Interestingly I actually found a bug in Chrome while implementing it. If you set the stroke width past a certain ratio to the font the underline is moved down from the baseline.

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.

Text Render With Underline And Tracking Not Rendered Properly

3 participants