-
Notifications
You must be signed in to change notification settings - Fork 68
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
Missing glyphs and inccorect breaks when setting MaxLines on TextBlock containing line breaks #65
Comments
Maybe it enough to always line break at a line break character if that occurs before the max width of the text block? E.g: diff --git a/Topten.RichTextKit/TextBlock.cs b/Topten.RichTextKit/TextBlock.cs
index 1b29bda..9403b80 100644
--- a/Topten.RichTextKit/TextBlock.cs
+++ b/Topten.RichTextKit/TextBlock.cs
@@ -1475,10 +1475,15 @@ namespace Topten.RichTextKit
fr = _fontRuns[frIndex];
var room = _maxWidthResolved - fr.XCoord;
frSplitIndex = frIndex;
- codePointIndexSplit = fr.FindBreakPosition(room, frSplitIndex == frIndexStartOfLine);
- codePointIndexWrap = codePointIndexSplit;
- while (codePointIndexWrap < _codePoints.Length && UnicodeClasses.LineBreakClass(_codePoints[codePointIndexWrap]) == LineBreakClass.SP)
- codePointIndexWrap++;
+ var breakPosition = fr.FindBreakPosition(room, frSplitIndex == frIndexStartOfLine);
+
+ if (breakPosition < codePointIndexSplit)
+ {
+ codePointIndexSplit = breakPosition;
+ codePointIndexWrap = codePointIndexSplit;
+ while (codePointIndexWrap < _codePoints.Length && UnicodeClasses.LineBreakClass(_codePoints[codePointIndexWrap]) == LineBreakClass.SP)
+ codePointIndexWrap++;
+ }
}
// Split it |
The patch above is a bit too naive since I'll submit a PR if testing is successful. |
Setting the
MaxLines
property on aTextBlock
that contains text with line breaks results in missing glyphs being rendered at the line break character positions.Repro:
Result:
![maxlines](https://user-images.githubusercontent.com/72543740/212681079-1abec7cc-4d4a-4f9e-9786-849257c5073b.png)
The text was updated successfully, but these errors were encountered: