Skip to content
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 Linebreak issues #443 and #444 #445

Merged
merged 3 commits into from
Jan 29, 2025

Conversation

JimBobSquarePants
Copy link
Member

@JimBobSquarePants JimBobSquarePants commented Jan 29, 2025

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 #443 and #444
I realised during debugging of this issue that I was attacking the problem incorrectly. Instead of looping though the codepoints in the single line and attempting to match the correct line break, I identify the correct break by measuring the line at each one then slicing the textline once the correct break has been identified. This approach avoids back searching and additional complexity, ensuring that the correct break is always used.

Choose a reason for hiding this comment

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

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

Files not reviewed (7)
  • tests/Images/ReferenceOutput/Issue_444_A__WrappingLength_860_.png: Language not supported
  • tests/Images/ReferenceOutput/Issue_444_B__WrappingLength_860_.png: Language not supported
  • tests/Images/ReferenceOutput/Issue_444_C__WrappingLength_860_.png: Language not supported
  • tests/Images/ReferenceOutput/Issue_444_D__WrappingLength_860_.png: Language not supported
  • tests/Images/ReferenceOutput/Issue_444_E__WrappingLength_860_.png: Language not supported
  • tests/Images/ReferenceOutput/ShouldBreakIntoTwoLinesA__WrappingLength_1000_.png: Language not supported
  • tests/Images/ReferenceOutput/ShouldBreakIntoTwoLinesB__WrappingLength_100_.png: Language not supported
Comments suppressed due to low confidence (3)

tests/SixLabors.Fonts.Tests/Issues/Issues_444.cs:10

  • [nitpick] The variable name 'charisSL' is inconsistent with the font name 'CharisSIL'. It should be renamed to 'charisSIL'.
private FontFamily charisSL = new FontCollection().Add(TestFonts.CharisSILRegular);

src/SixLabors.Fonts/TextLayout.cs:1382

  • The method signature of InsertAt was changed to void, but the return statement was not removed. This could lead to confusion.
RecalculateLineMetrics(this);

src/SixLabors.Fonts/TextLayout.cs:1353

  • The variable graphemeIndex was renamed to graphemeCodePointIndex in one place but not consistently throughout the code. This could lead to confusion.
if (graphemeCodePointIndex == 0)
@JimBobSquarePants JimBobSquarePants linked an issue Jan 29, 2025 that may be closed by this pull request
4 tasks
tocsoft
tocsoft previously approved these changes Jan 29, 2025
@jez9999
Copy link

jez9999 commented Jan 29, 2025

charisSL variable should presumably be charisSIL.

@JimBobSquarePants JimBobSquarePants merged commit b98614c into main Jan 29, 2025
8 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/additional-linebreak-fixes branch January 29, 2025 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants