Browse Source

app: most basic RTL support (non-joining chars)

darkfi 1 year ago
parent
commit
83fa980007
1 changed files with 4 additions and 1 deletions
  1. 4 1
      bin/app/src/text/shape.rs

+ 4 - 1
bin/app/src/text/shape.rs

@@ -120,7 +120,10 @@ pub(super) struct GlyphInfo {
 
 impl GlyphInfo {
     pub fn substr<'a>(&self, text: &'a str) -> &'a str {
-        &text[self.cluster_start..self.cluster_end]
+        // RTL
+        let start = std::cmp::min(self.cluster_start, self.cluster_end);
+        let end = std::cmp::max(self.cluster_start, self.cluster_end);
+        &text[start..end]
     }
 }