diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-31 13:55:33 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-31 13:55:33 -0400 |
commit | 137b79e4ed980e1fc688f7c8f2c07ef4f9e30050 (patch) | |
tree | 15cc80501dfbcfd19cd71513fe787d30e96fcf92 /src/cell.rs | |
parent | 085115797e5698f1fa4599de41863999050d4b98 (diff) | |
download | vt100-rust-137b79e4ed980e1fc688f7c8f2c07ef4f9e30050.tar.gz vt100-rust-137b79e4ed980e1fc688f7c8f2c07ef4f9e30050.zip |
add normalization for unicode cell values
Diffstat (limited to 'src/cell.rs')
-rw-r--r-- | src/cell.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cell.rs b/src/cell.rs index 3d2a9fa..370feb0 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -1,3 +1,5 @@ +use unicode_normalization::UnicodeNormalization as _; + #[derive(Clone, Debug, Default)] pub struct Cell { contents: String, @@ -16,6 +18,12 @@ impl Cell { pub(crate) fn append(&mut self, c: char) { self.contents.push(c); + // some fonts have combined characters but can't render combining + // characters correctly, so try to prefer precombined characters when + // possible + if !unicode_normalization::is_nfc(&self.contents) { + self.contents = self.contents.nfc().collect(); + } } pub(crate) fn reset(&mut self) { |