Proposal: Hyphenation support in WinUI
See original GitHub issueProposal: Hyphenation support in WinUI
WPF had it, the web has it, WinUI needs it. Please add support for soft-hyphens to TextBlocks and other UI elements. Currently words will be either wrapped to a new line at the letter that doesn’t fit anymore, on a whitspace or not at all.
A soft-hyphen is the typographic correct way to indicate an appropriate place in a word to wrap to a new line. So if TextTrimming is set to WrapWholeWords, and if the word contains a unicode soft hypen character (U+00AD
, often encoded as ­
), this character should be used to split the word on two lines with a hypen at the end of the first line.
I believe good algorithms to determine whether to break at a soft-hypen are well understood and implemented in many projects (including Edge, WPF, Word, etc.).
Rationale
Modern typography features are a major draw for developers to adopt WinUI, lets make sure WinUI is really up to par with other platforms.
This is an increasingly important feature if you take internationalization into account, where texts live independent of the box sizes they occupy in a resource file. Additionally, in certain languages (esp. German) long words are much more common and exacerbate the need for this feature.
Stretch goal
A good follow up to this proposal would be a dictionary or algorithm based “auto-hyphenation” feature like some browsers and Word implement. This is especially important with justified text that is a bit longer (think a newspaper-like slim column text layout).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:7 (5 by maintainers)
Top GitHub Comments
Keep alive (re #8638)
I’ve had this problem in one of my projects before, and using a zero-width space does work. WinUI will split the word at the ZWS if it needs to. It doesn’t render a hyphen or anything, but if you just need a line break it’s fine.