cosmic-text
cosmic-text copied to clipboard
Numbers inside of a mixed RTL/LTR line cause issues with the layout
There is an issue with numbers inside a mixed RTL/LTR sentence. Currently a span only contains a boolean that says if it is RTL or LTR. To get a correct layout we need to also consider the BidiClass. Some Bidi Class values are strong LTR or RTL, but some are Weak or Neutral which means when we are creating the layout although the span might be written LTR for layouting purposes it should be treated as an RTL span (if the surrounding text is also RTL).
The simplest example is numbers. Consider the following example:
The latest version of Pop OS is 22.04. آخرین ورژن سیستم عامل پاپ ۲۲.۰۴ است.
This is currently rendered like this:
As you can see the numbers in the RTL span are treated as an LTR span which causes the layout to mess up.