Skip to content

Do not justify last line.#525

Merged
JimBobSquarePants merged 3 commits intomainfrom
js/fix-justify
Apr 15, 2026
Merged

Do not justify last line.#525
JimBobSquarePants merged 3 commits intomainfrom
js/fix-justify

Conversation

@JimBobSquarePants
Copy link
Copy Markdown
Member

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

Refactors how text justification is handled in the TextLayout process. The change defers justification until after all lines are split, ensuring that only the appropriate lines are justified and metrics are recalculated correctly.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82%. Comparing base (6df7590) to head (cbdfdee).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/SixLabors.Fonts/TextLayout.cs 77% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #525   +/-   ##
=====================================
- Coverage     82%     82%   -1%     
=====================================
  Files        305     305           
  Lines      21618   21628   +10     
  Branches    3196    3200    +4     
=====================================
+ Hits       17875   17881    +6     
- Misses      2932    2934    +2     
- Partials     811     813    +2     
Flag Coverage Δ
unittests 82% <77%> (-1%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors text layout justification so it’s applied after line splitting, aiming to avoid justifying the final line and to ensure line metrics are recalculated at the right time.

Changes:

  • Moves justification out of TextLine.Finalize(...) and into a post-pass after BreakLines() has produced all lines.
  • Updates TextLine.Justify(...) to recalculate line metrics after modifying glyph advances.
  • Updates reference image outputs for text-justification tests (LFS pointers updated).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/SixLabors.Fonts/TextLayout.cs Defers justification until after line breaking; adjusts finalize/justify responsibilities and metrics recalculation.
tests/Images/ReferenceOutput/TextJustification_InterWord_Vertical_400-direction_RightToLeft-TextJustification_InterWord.png Updates expected rendered output (Git LFS pointer change).
tests/Images/ReferenceOutput/TextJustification_InterWord_Vertical_400-direction_LeftToRight-TextJustification_InterWord.png Updates expected rendered output (Git LFS pointer change).
tests/Images/ReferenceOutput/TextJustification_InterWord_Horizontal_400-direction_RightToLeft-TextJustification_InterWord.png Updates expected rendered output (Git LFS pointer change).
tests/Images/ReferenceOutput/TextJustification_InterWord_Horizontal_400-direction_LeftToRight-TextJustification_InterWord.png Updates expected rendered output (Git LFS pointer change).
tests/Images/ReferenceOutput/TextJustification_InterCharacter_Vertical_400-direction_RightToLeft-TextJustification_InterCharacter.png Updates expected rendered output (Git LFS pointer change).
tests/Images/ReferenceOutput/TextJustification_InterCharacter_Vertical_400-direction_LeftToRight-TextJustification_InterCharacter.png Updates expected rendered output (Git LFS pointer change).
tests/Images/ReferenceOutput/TextJustification_InterCharacter_Horizontal_400-direction_RightToLeft-TextJustification_InterCharacter.png Updates expected rendered output (Git LFS pointer change).
tests/Images/ReferenceOutput/TextJustification_InterCharacter_Horizontal_400-direction_LeftToRight-TextJustification_InterCharacter.png Updates expected rendered output (Git LFS pointer change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/SixLabors.Fonts/TextLayout.cs Outdated
Comment thread src/SixLabors.Fonts/TextLayout.cs Outdated
Comment thread src/SixLabors.Fonts/TextLayout.cs Outdated
Comment thread src/SixLabors.Fonts/TextLayout.cs
Comment thread src/SixLabors.Fonts/TextLayout.cs
@JimBobSquarePants JimBobSquarePants merged commit 4b403a7 into main Apr 15, 2026
10 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/fix-justify branch April 15, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants