Просмотр исходного кода

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

darkfi 1 год назад
Родитель
Сommit
83fa980007
1 измененных файлов с 4 добавлено и 1 удалено
  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 {
 impl GlyphInfo {
     pub fn substr<'a>(&self, text: &'a str) -> &'a str {
     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]
     }
     }
 }
 }