cosmic-text icon indicating copy to clipboard operation
cosmic-text copied to clipboard

Numbers inside of a mixed RTL/LTR line cause issues with the layout

Open hojjatabdollahi opened this issue 1 year ago • 0 comments

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:

farsi

As you can see the numbers in the RTL span are treated as an LTR span which causes the layout to mess up.

hojjatabdollahi avatar Nov 08 '22 04:11 hojjatabdollahi