Skip to content

Commit

Permalink
Support lots of ligatures (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-Bertholet authored Jun 6, 2024
1 parent de1846a commit afab363
Show file tree
Hide file tree
Showing 9 changed files with 29,184 additions and 20,311 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ jobs:
- name: Check formatting
run: cargo fmt --check
- name: Check clippy
run: cargo clippy --lib --tests
run: cargo clippy --verbose --lib --tests
- name: Build (no default features)
run: cargo build --verbose --no-default-features
- name: Run tests (no default features)
run: cargo test --verbose --no-default-features
- name: Check clippy (no default features)
run: cargo clippy --verbose --lib --tests --no-default-features

regen:
runs-on: ubuntu-latest
Expand All @@ -37,6 +43,6 @@ jobs:
with:
python-version: '3.12'
- name: Regen
run: rm tests/NormalizationTest.txt && cd scripts && python3 unicode.py
run: rm tests/emoji-test.txt && cd scripts && python3 unicode.py
- name: Diff
run: git update-index --refresh && git diff-index --quiet HEAD --
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ core = { version = "1.0", package = "rustc-std-workspace-core", optional = true
compiler_builtins = { version = "0.1", optional = true }

[features]
default = []
cjk = []
default = ["cjk"]
rustc-dep-of-std = ['std', 'core', 'compiler_builtins']

# Legacy, now a no-op
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,26 @@ fn main() {
```

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

```rust
extern crate unicode_width;
use unicode_width::UnicodeWidthStr;

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

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

## crates.io

Expand Down
Loading

0 comments on commit afab363

Please sign in to comment.