Silverlight的TextWrapping的分裂字符是什么?

时间:2021-10-29 03:25:34

The TextWrapping feature in Silverlight is described here. However, I'm trying to find out the details of their line-breaking algorithm.

本文描述了Silverlight中的TextWrapping特性。然而,我正在尝试找出他们的断行算法的细节。

Obviously a space will cause the text to break (or split), encouraging the text to wrap to the next line. And through trial and error I've found that these characters also cause a split:

显然,空格会导致文本中断(或分裂),从而鼓励文本向下一行进行换行。通过反复试验,我发现这些字符也会导致分裂:

  • \t (tab)
  • \ t(选项卡)
  • -
  • - - - - - -
  • !
  • !
  • ?
  • 吗?

But I doubt this is the full list. Has anyone found the full list of split characters (including Unicode)? Or do you have any clever suggestions for figuring this out that I haven't thought of yet? Trial and error can be slow.

但我怀疑这是不是完整的列表。有没有人找到分裂字符的完整列表(包括Unicode)?或者你有什么聪明的建议来解决这个问题我还没想过呢?尝试和错误可能是缓慢的。

3 个解决方案

#1


2  

I'd guess every character that qualifies as space or punctuation, excluding the explicitly non-breaking characters.

我猜所有符合空格或标点符号的字符,都不包括显式的不间断字符。

However, there is a specified algorithm for line breaking: Unicode Standard Annex #14: Unicode Line Breaking Algorithm.

但是,有一个指定的断行算法:Unicode标准附件#14:Unicode断行算法。

#2


4  

TextWrapping = Wrap will attempt to conform to the the standard Unicode Standard Annex #14 that Johannes has already linked.

TextWrapping = Wrap将尝试符合标准Unicode标准附件#14,Johannes已经链接。

However if using this approach the text still doesn't fit the width (due to very limited width or long words) then it'll break the word across two lines, it doesn't hyphnate or do anything clever. As soon a placing a letter would overrun the width and if it can't find something in the line that'll let it use the standard algorithm it'll continue the word on the next line.

但是,如果使用这种方法,文本仍然不适合宽度(由于宽度非常有限或单词太长),那么它会跨两行将单词分隔开,它不会连字符或做任何聪明的事情。一旦放置一个字母就会超过宽度,如果它在一行中找不到什么东西让它使用标准的算法,它将在下一行继续这个单词。

#3


1  

I wrote a little test app to help me determine which of these characters cause a split. It's still a manual process but at least it's easier to look at now. The script started at ASCII code 1 and I've gone up to 3000.

我编写了一个小测试应用程序来帮助我确定这些字符中哪一个会导致分裂。这仍然是一个手工过程,但至少现在看起来更容易。这个脚本从ASCII码1开始,现在已经达到3000。

These cause a split after the character:

这些导致了角色的分裂:

Private arrSplitAfter() As Char = {CChar(" "), CChar("-"), ChrW(9), CChar("!"), CChar("?"), CChar("%"), CChar(")"), CChar("/"), CChar("]"), CChar("|"), CChar("}"), ChrW(133), ChrW(162), ChrW(176), ChrW(1418), ChrW(1478), ChrW(1547), ChrW(1548), ChrW(1563), ChrW(1566), ChrW(1567), ChrW(1642), ChrW(1748), ChrW(2404), ChrW(2405)}

And these cause a split before the character:

这些导致了角色的分裂:

Private arrSplitBefore() As Char = {CChar("$"), CChar("("), CChar("+"), CChar("["), CChar("\"), CChar("{"), ChrW(163), ChrW(164), ChrW(165), ChrW(177), ChrW(180), ChrW(712), ChrW(716), ChrW(2546), ChrW(2547), ChrW(2801)}

Obviously there are a lot more characters to go. Unfortunately I've run into a hiccup. I was trying to write some super efficient highlighting code that would work on word-wrapped text. Until I can figure out a solution for my highlighting issues I won't bother continuing.

显然,还有更多的角色要演。很不幸,我打嗝了。我试着写一些非常高效的高亮代码,它可以处理文字包装的文本。直到我能找到解决问题的方法,我才不会继续下去。

#1


2  

I'd guess every character that qualifies as space or punctuation, excluding the explicitly non-breaking characters.

我猜所有符合空格或标点符号的字符,都不包括显式的不间断字符。

However, there is a specified algorithm for line breaking: Unicode Standard Annex #14: Unicode Line Breaking Algorithm.

但是,有一个指定的断行算法:Unicode标准附件#14:Unicode断行算法。

#2


4  

TextWrapping = Wrap will attempt to conform to the the standard Unicode Standard Annex #14 that Johannes has already linked.

TextWrapping = Wrap将尝试符合标准Unicode标准附件#14,Johannes已经链接。

However if using this approach the text still doesn't fit the width (due to very limited width or long words) then it'll break the word across two lines, it doesn't hyphnate or do anything clever. As soon a placing a letter would overrun the width and if it can't find something in the line that'll let it use the standard algorithm it'll continue the word on the next line.

但是,如果使用这种方法,文本仍然不适合宽度(由于宽度非常有限或单词太长),那么它会跨两行将单词分隔开,它不会连字符或做任何聪明的事情。一旦放置一个字母就会超过宽度,如果它在一行中找不到什么东西让它使用标准的算法,它将在下一行继续这个单词。

#3


1  

I wrote a little test app to help me determine which of these characters cause a split. It's still a manual process but at least it's easier to look at now. The script started at ASCII code 1 and I've gone up to 3000.

我编写了一个小测试应用程序来帮助我确定这些字符中哪一个会导致分裂。这仍然是一个手工过程,但至少现在看起来更容易。这个脚本从ASCII码1开始,现在已经达到3000。

These cause a split after the character:

这些导致了角色的分裂:

Private arrSplitAfter() As Char = {CChar(" "), CChar("-"), ChrW(9), CChar("!"), CChar("?"), CChar("%"), CChar(")"), CChar("/"), CChar("]"), CChar("|"), CChar("}"), ChrW(133), ChrW(162), ChrW(176), ChrW(1418), ChrW(1478), ChrW(1547), ChrW(1548), ChrW(1563), ChrW(1566), ChrW(1567), ChrW(1642), ChrW(1748), ChrW(2404), ChrW(2405)}

And these cause a split before the character:

这些导致了角色的分裂:

Private arrSplitBefore() As Char = {CChar("$"), CChar("("), CChar("+"), CChar("["), CChar("\"), CChar("{"), ChrW(163), ChrW(164), ChrW(165), ChrW(177), ChrW(180), ChrW(712), ChrW(716), ChrW(2546), ChrW(2547), ChrW(2801)}

Obviously there are a lot more characters to go. Unfortunately I've run into a hiccup. I was trying to write some super efficient highlighting code that would work on word-wrapped text. Until I can figure out a solution for my highlighting issues I won't bother continuing.

显然,还有更多的角色要演。很不幸,我打嗝了。我试着写一些非常高效的高亮代码,它可以处理文字包装的文本。直到我能找到解决问题的方法,我才不会继续下去。