-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix calculation of wrapping advance #440
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 17 changed files in this pull request and generated no comments.
Files not reviewed (14)
- tests/Images/ReferenceOutput/CountLinesWrappingLength_100-3.png: Language not supported
- tests/Images/ReferenceOutput/CountLinesWrappingLength_100-4.png: Language not supported
- tests/Images/ReferenceOutput/CountLinesWrappingLength_50-4.png: Language not supported
- tests/Images/ReferenceOutput/CountLinesWrappingLength_50-5.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordBreakMatchesMDN_238-layoutMode_HorizontalBottomTop-wordBreaking_BreakAll.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordBreakMatchesMDN_238-layoutMode_HorizontalTopBottom-wordBreaking_BreakAll.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordBreak_500-layoutMode_HorizontalBottomTop-wordBreaking_BreakAll.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordBreak_500-layoutMode_HorizontalTopBottom-wordBreaking_BreakAll.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordWrappingHorizontalBottomTop_350-height_62.625-width_318.86.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordWrappingHorizontalTopBottom_350-height_62.625-width_318.86.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordWrappingVerticalLeftRight_350-height_318.563-width_62.813.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordWrappingVerticalMixedLeftRight_350-height_318.563-width_62.813.png: Language not supported
- tests/Images/ReferenceOutput/MeasureTextWordWrappingVerticalRightLeft_350-height_318.563-width_62.813.png: Language not supported
- tests/Images/ReferenceOutput/ShouldNotInsertExtraLineBreaks_2__WrappingLength_400_.png: Language not supported
Comments suppressed due to low confidence (4)
tests/SixLabors.Fonts.Tests/Issues/Issues_431.cs:35
- Ensure that the new test case
ShouldNotInsertExtraLineBreaks_2
covers the new behavior correctly, especially with the changes in theBreakLines
method.
public void ShouldNotInsertExtraLineBreaks_2()
src/SixLabors.Fonts/TextLayout.cs:1077
- The comment about using inches for comparison is misleading since the actual comparison is done in pixels after conversion. Consider rephrasing to clarify the intent.
// Now scale the advance. We use inches for comparison.
src/SixLabors.Fonts/TextLayout.cs:1156
- Re-initializing
lineAdvance
here might be unnecessary and could lead to confusion. Ensure thatlineAdvance
is correctly managed within the loop.
float lineAdvance = 0;
src/SixLabors.Fonts/TextLayout.cs:1175
- Resetting
i
to-1
might cause an off-by-one error. Verify if this is the intended behavior or ifi
should be reset to0
.
i = -1;
if (codePointIndex == currentLineBreak.PositionWrap && currentLineBreak.Required) | ||
{ | ||
// Mandatory line break at index. | ||
TextLine remaining = textLine.SplitAt(i); | ||
textLines.Add(textLine.Finalize(options)); | ||
textLine = remaining; | ||
i = 0; | ||
i = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This took me a few hours to figure out! Setting i = 0
was incorrect as the loop was incrementing the value before we read the collection again.
👍 With 2.0.9 all my tests now seem to render as expected. |
Apparently I spoke too soon. 😞 Came across another regression by accident. Filed as #441. |
Prerequisites
Description
An index mismatch was causing the incorrect line-break to be used under certain circumstance.
CC @jez9999