-
-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matrix Display output alignment is not Unicode-aware #1354
Comments
Is there a reason to put Chinese characters in an |
Some people may prefer to output numbers in Chinese numerals instead of the Arabic numeral system. A cursory glance at crates.io doesn't reveal any crates that have |
A potential solution would be to allow trait overloading for computing the length of a scalar in characters, at the level of the scalar. This would not help you if you were printing a @Ralith I don't believe that Hanzi numerals are popular in mathematical work, but fullwidth numerals can be useful for alignment purposes; e.g. in terminals well-formatted CJK characters tend to take up two horizontal cells rather than one, so using fullwidth numerals can be useful. However I think those will actually work fine, as it's a char-count and not a byte-count, so the fullwidth forms should be aligned correctly relative to one another, as long as they aren't being constructed using CJK combining characters (which are sadly not that well-supported anywhere, in my experience.) |
Another use case, beyond mine, is computer algebra systems or other libraries that want to implement symbolic expressions. Perhaps that's more common than different languages. You make an excellent point—allowing the custom types to control their display width eliminates my main concern with a fix for this, the large size of The An important note is that fixing the issue on my end is more challenging than I originally thought. One solution I had considered was to add zero-width characters to the |
Hi,
Thanks for all the wonderful work on this library. I'm coming back after a Rust hiatus and I can't believe the const generics work as well as they do.
I'm using a custom scalar type that uses a combining overline character instead of a minus sign, to match the style of this reference work:
Somewhat ironically, a typesetting convention designed to make alignment easier in print breaks alignment for
Matrix
output using this custom type:The
Display
implementation here uses.char().count()
instead of grapheme counting, which is what causes the misalignment seen here. I imagine this would also affect less frivolous customDisplay
impls, like Chinese characters.unicode-segmentation
is a large dependency to make a tiny edge case look nicer, so I'm not exactly saying this should be implemented differently, but I'd be interested if anyone else has had this issue or if there's a solution that doesn't require increasing the code size too massively.The text was updated successfully, but these errors were encountered: