I have a bit long RTL (Hebrew) texts that I want to display in full (on multiple lines, without wrapping), and some of them keep getting overflown/cut-off on right, no matter how I tried to fix it. I guess it depends on the way SwiftUI renders those texts.
This is actually a problem in the Text component but it worth mentioning that I tried contain the items in both List and ScrollView, without success to fix the problem (while ScrollView yeilded a bit better results). This how it looks:
https://i.stack.imgur.com/35Pc9.png
Example for a "bad" text (on iPhone 11 Pro Max):
פגשדשעצשדלעצשדלעצשדלעצשלדצע שדצגךגתךת שדכצשדלכצדלעצשדלעצדשלעצשדלעשדלעצשדלעצשכידי געדגדגיג גיחלג דגחידחד דגיכחדגחדגח דחדכחדגחדגחחחחחחחחחחדלעצשדלעצשדלעצדשצעשדעגצ לגצעלדשצעכשלדעצלשד שדלעצשדלע שלדצעלשדעדלשעצשליפיDoes anyone has a clue how can I fix this issue?
I've ported this question from StackOverflow as no one was able to help there:
This is the ScrollView:
ScrollView {
VStack(alignment: .leading, spacing: 10) {
ForEach(self.items, id: \.id) { item in
item
}
}
}And this is an item:
var body: some View {
VStack(alignment: .leading) {
HStack {
Text(caption)
.font(.caption)
Text(formatDate(date: date))
.font(.caption)
.foregroundColor(.gray)
}
Text(text)
.font(.body)
.fixedSize(horizontal: false, vertical: true)
}
.padding()
}I'm using .environment(\.layoutDirection, .rightToLeft) on the ContentView:
let contentView = ContentView()
.environment(\.colorScheme, .dark)
.environment(\.layoutDirection, .rightToLeft)Thanks,
Uri