Skip to content

Commit afab363

Browse files
Support lots of ligatures (#53)
1 parent de1846a commit afab363

File tree

9 files changed

+29184
-20311
lines changed

9 files changed

+29184
-20311
lines changed

.github/workflows/rust.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ jobs:
2727
- name: Check formatting
2828
run: cargo fmt --check
2929
- name: Check clippy
30-
run: cargo clippy --lib --tests
30+
run: cargo clippy --verbose --lib --tests
31+
- name: Build (no default features)
32+
run: cargo build --verbose --no-default-features
33+
- name: Run tests (no default features)
34+
run: cargo test --verbose --no-default-features
35+
- name: Check clippy (no default features)
36+
run: cargo clippy --verbose --lib --tests --no-default-features
3137

3238
regen:
3339
runs-on: ubuntu-latest
@@ -37,6 +43,6 @@ jobs:
3743
with:
3844
python-version: '3.12'
3945
- name: Regen
40-
run: rm tests/NormalizationTest.txt && cd scripts && python3 unicode.py
46+
run: rm tests/emoji-test.txt && cd scripts && python3 unicode.py
4147
- name: Diff
4248
run: git update-index --refresh && git diff-index --quiet HEAD --

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ core = { version = "1.0", package = "rustc-std-workspace-core", optional = true
3232
compiler_builtins = { version = "0.1", optional = true }
3333

3434
[features]
35-
default = []
35+
cjk = []
36+
default = ["cjk"]
3637
rustc-dep-of-std = ['std', 'core', 'compiler_builtins']
3738

3839
# Legacy, now a no-op

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,26 @@ fn main() {
2525
```
2626

2727
**NOTE:** The computed width values may not match the actual rendered column
28-
width. For example, the woman scientist emoji comprises of a woman emoji, a
29-
zero-width joiner and a microscope emoji. Such [emoji ZWJ sequences](https://www.unicode.org/reports/tr51/#Emoji_ZWJ_Sequences)
30-
are considered to have the sum of the widths of their constituent parts:
28+
width. For example, many Brahmic scripts like Devanagari have complex rendering rules
29+
which this crate does not currently handle (and will never fully handle, because
30+
the exact rendering depends on the font):
3131

3232
```rust
3333
extern crate unicode_width;
3434
use unicode_width::UnicodeWidthStr;
3535

3636
fn main() {
37-
assert_eq!("👩".width(), 2); // Woman
38-
assert_eq!("🔬".width(), 2); // Microscope
39-
assert_eq!("👩‍🔬".width(), 4); // Woman scientist
37+
assert_eq!("".width(), 1); // Devanagari letter Ka
38+
assert_eq!("".width(), 1); // Devanagari letter Ssa
39+
assert_eq!("क्ष".width(), 2); // Ka + Virama + Ssa
4040
}
4141
```
4242

4343
Additionally, [defective combining character sequences](https://unicode.org/glossary/#defective_combining_character_sequence)
4444
and nonstandard [Korean jamo](https://unicode.org/glossary/#jamo) sequences may
4545
be rendered with a different width than what this crate says. (This is not an
46-
exhaustive list.)
46+
exhaustive list.) For a list of what this crate *does* handle, see
47+
[docs.rs](https://docs.rs/unicode-width/latest/unicode_width/#rules-for-determining-width).
4748

4849
## crates.io
4950

0 commit comments

Comments
 (0)