runefix_core/lib.rs
1//! # runefix-core
2//!
3//! Unicode-aware display width engine for terminals, TUI, and Markdown rendering.
4//!
5//! This crate provides precise width computation for multilingual text, including:
6//!
7//! - East Asian fullwidth characters (CJK)
8//! - Emoji (including ZWJ sequences)
9//! - Fullwidth punctuation and symbol variants
10//! - Grapheme-aware string truncation and wrapping
11//!
12//! It ensures text alignment is consistent across platforms and fonts by working at
13//! the grapheme cluster level and consulting curated Unicode-derived datasets.
14//!
15//! ## Features
16//!
17//! - `get_display_width`: Width of a single grapheme or string
18//! - `split_graphemes`: Unicode-aware character segmentation
19//! - `truncate_by_width`: Safe truncation without splitting emoji/CJK
20//! - `split_by_width`: Line wrapping by column width
21//!
22//! ## Example
23//!
24//! ```rust
25//! use runefix_core::{RuneDisplayWidth, grapheme_widths};
26//!
27//! assert_eq!('你'.rune_width(), 2);
28//! assert_eq!(
29//! grapheme_widths("Hi,世界"),
30//! vec![("H", 1), ("i", 1), (",", 2), ("世", 2), ("界", 2)]
31//! );
32//! ```
33//!
34//! See [README](https://github.com/pokeyaro/runefix-rs/tree/main/crates/core) for dataset source and usage details.
35
36/// Re-exports: Primary public API
37pub use grapheme::{
38 display_width,
39 display_widths,
40 grapheme_widths,
41 split_graphemes,
42 truncate_by_width,
43 split_by_width
44};
45pub use ext::RuneDisplayWidth;
46pub use consts::UNICODE_VERSION;
47
48// Internal modules (not re-exported directly)
49mod consts;
50mod rules;
51mod width;
52mod grapheme;
53mod ext;