aboutsummaryrefslogtreecommitdiffstats
path: root/src/cell.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-23 13:17:55 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-23 13:33:41 -0500
commitdf312db3c428e7e8936c5ad6846629236bcb6240 (patch)
treebb8ca39f256cf4605cacd78782f80fdbb0e82ec6 /src/cell.rs
parentcd94e2ccb2272286fd0e2bc8ae67db2fba5276e5 (diff)
downloadvt100-rust-df312db3c428e7e8936c5ad6846629236bcb6240.tar.gz
vt100-rust-df312db3c428e7e8936c5ad6846629236bcb6240.zip
make unicode normalization optional
it's not always necessary or desired, and adds quite a lot to the binary size (for instance, the problem it solves is pretty much non-existent in web browsers, and wasm builds are also very sensitive to code size)
Diffstat (limited to 'src/cell.rs')
-rw-r--r--src/cell.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/cell.rs b/src/cell.rs
index 05d93be..ecc44b2 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -1,4 +1,3 @@
-use unicode_normalization::UnicodeNormalization as _;
use unicode_width::UnicodeWidthChar as _;
const CODEPOINTS_IN_CELL: usize = 6;
@@ -49,6 +48,18 @@ impl Cell {
self.contents[self.len()] = c;
self.len += 1;
+ self.normalize();
+ }
+
+ #[cfg(not(feature = "unicode-normalization"))]
+ #[inline]
+ fn normalize(&mut self) {}
+
+ #[cfg(feature = "unicode-normalization")]
+ #[inline]
+ fn normalize(&mut self) {
+ use unicode_normalization::UnicodeNormalization as _;
+
// some fonts have combined characters but can't render combining
// characters correctly, so try to prefer precombined characters when
// possible