how to display LTR text within an RTL language con...
# compose-android
h
how to display LTR text within an RTL language context?
e
a sequence of Latin characters will default to LTR display within a RTL context
you can also override the layout direction with a part of the hierarchy,
Copy code
CompositionLocalProvider(
    LocalLayoutDirection provides LayoutDirection.Ltr
) {
    ...
}
or as a last-ditch workaround, use Unicode bidi overrides within a string, https://www.w3.org/International/questions/qa-bidi-unicode-controls
h
this was the problem statement : Consider the case where I am developing a “quotes app” and I want to use the precise phrases in the same language that the famous philosophers themselves stated . Therefore, some quotes will be RTL and some LTR. And I want them to be that way unaffected by the language of the user’s device. How can I do this? and this is I ended up with :
Copy code
Column {
        Text(
            text = "Hello World....",
            style = TextStyle(textDirection = TextDirection.Ltr),
            modifier = Modifier.fillMaxWidth(),
        )
        Text(
            text = "السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ",
            style = TextStyle(textDirection = TextDirection.Rtl),
            modifier = Modifier.fillMaxWidth()
        )
    }
by the way thanks
e
as long as the text script is strongly directional (which should normally be the case), it will display in the correct reading order regardless of the layout direction
👍 1
122 Views