aboutsummaryrefslogtreecommitdiffstats
path: root/src/cell.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-10-31 13:55:33 -0400
committerJesse Luehrs <doy@tozt.net>2019-10-31 13:55:33 -0400
commit137b79e4ed980e1fc688f7c8f2c07ef4f9e30050 (patch)
tree15cc80501dfbcfd19cd71513fe787d30e96fcf92 /src/cell.rs
parent085115797e5698f1fa4599de41863999050d4b98 (diff)
downloadvt100-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.rs8
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) {