Comments (2)
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
from richtextkit.
The patch above is a bit too naive since codePointIndexSplit
can be negative if no non-character breaks were found. I have modified it for our use-case such that it differentiates between required text breaks and others, and that it prefers to break at characters if that happens later than a break position (leads to behavior similar to StringTrimming.EllipsisCharacter
in GDI+).
I'll submit a PR if testing is successful.
from richtextkit.
Related Issues (20)
- Add strong name for .NET framework HOT 1
- StrikeThrough and Underline not visible for certain fonts and small sizes HOT 4
- Different line break behavior based on how texts are added HOT 1
- MessuredHeight hangs on Linux HOT 2
- Missing glyphs when rendering clusters with unmatched combining characters HOT 1
- [Bug]Pagewidth does not work on white spaces
- Is this library still active? HOT 2
- Throw a more informative exception when FontFamily is missing from the Style specified in a TextBlock
- Underline and StrikeThrough incorrect when given font size is very smaller HOT 2
- SKPaint and performance considerations HOT 4
- Distinguish between italic and oblique variants of a font HOT 2
- [Bug] LetterSpacing not working when using on part of the text only
- [Bug] Subscript and Superscript not working when using on part of the text only
- [Question or Feature Request] How to determine "overbounds"?
- Annoying style issue with paragraph separators HOT 1
- Word-based-navigation fails if word has " in front
- Text with custom font is not rendered if the height of the text to draw equals the MaxHeight HOT 1
- Support for TextAlignment.Justify HOT 1
- TextColor of RichString method does not work after construction
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from richtextkit.