问题
I'm looking for a sample project that will perform hyphenation of text in C#. Ideally, this would be derived from the TeX hyphenation algorithm, or similar. I'm interested in English currently, although other languages may be required in the future. Anyone seen something like that? background I'm planning on including this in a MonoTouch project using CoreText.
回答1:
Obviously, Donald Knuth's algorithms are excellent. Although there is not a C# implementation available, have you considered converting another implementation to C#? (For example, you could convert the Java implementation which is fairly close to C#.)
Another option is to use a simpler implementation which can be found over at this answer here on StackOverflow.
回答2:
I found a C# implementation of Knuth-Liang hyphenation algorithm at https://github.com/alkozko/NHyphenator and it seems to work fine.
But there are currently two drawbacks:
- It can't load TeX hyphenation pattern files out-of-the-box (however, adding support for them seems trivial).
- It's unclear which kind of license applies to the source code.
来源:https://stackoverflow.com/questions/5877777/hyphenation-in-c-sharp