Soft hyphens or hyphens in text blocks

I have a Windows 8 style studio page with snippets that contain large text in TextBlocks. In some locations, the text is too long for one line and must be wrapped. By default, wrappers are performed only in spaces and hyphens. But sometimes even single words are too long and they also need to be wrapped.

enter image description here

image description: 3 blue tiles: "Text", "A few short words BREAK BREAK", "Antidisesta BREAK blishesa BREAK rianism"

I want the wrapping in words to be typographically correct, i.e. with hyphens and in the correct positions (and not just after the last letter that fits into the string).

In WPF, I solved a similar problem by placing soft hyphens in the text as hyphenation tips.

When calculating and typing, a soft hyphen [..] is a kind of hyphen used to indicate a place in the text where hyphenation is allowed without forcing a line break in an uncomfortable place if the text re-leaks.

Unfortunately, it does not work in XAML infrastructure . They are simply ignored. Spaces of zero width .

Is there a way to make soft hyphens? Or any other way to insert carry hints?

Note I know that I could hard-code hyphens / breaks by writing "Antidises-tablish-mentaria-nism", but this will snap the string to a specific (size) TextBlock and create super dense inextricable hyphens of the middle word in other text blocks. I want to avoid this.

+4
source share
1 answer

Soft hyphens are usually implemented using "U + 00AD", but they are ignored in WinRT. You can use RichTextBlock with the coding "-".

-1
source

Source: https://habr.com/ru/post/1488663/


All Articles