Expand description
§runefix-core
Unicode-aware display width engine for terminals, TUI, and Markdown rendering.
This crate provides precise width computation for multilingual text, including:
- East Asian fullwidth characters (CJK)
- Emoji (including ZWJ sequences)
- Fullwidth punctuation and symbol variants
- Grapheme-aware string truncation and wrapping
It ensures text alignment is consistent across platforms and fonts by working at the grapheme cluster level and consulting curated Unicode-derived datasets.
§Features
get_display_width: Width of a single grapheme or stringsplit_graphemes: Unicode-aware character segmentationtruncate_by_width: Safe truncation without splitting emoji/CJKsplit_by_width: Line wrapping by column width
§Example
use runefix_core::{RuneDisplayWidth, grapheme_widths};
assert_eq!('你'.rune_width(), 2);
assert_eq!(
grapheme_widths("Hi,世界"),
vec![("H", 1), ("i", 1), (",", 2), ("世", 2), ("界", 2)]
);See README for dataset source and usage details.
Constants§
- UNICODE_
VERSION - Unicode Version used by this build (auto-synced). auto-updated: 2025-05-26
Traits§
- Rune
Display Width - Extension trait for measuring the display width of runes, graphemes, and strings.
Functions§
- display_
width - Re-exports: Primary public API Returns the total display width (in columns) of a string, based on grapheme clusters.
- display_
widths - Re-exports: Primary public API Returns the display width (in columns) of each grapheme cluster in the input string.
- grapheme_
widths - Re-exports: Primary public API Returns the display width of each grapheme cluster in the input string.
- split_
by_ width - Re-exports: Primary public API Splits a string into lines based on display width, preserving grapheme boundaries.
- split_
graphemes - Re-exports: Primary public API Returns all grapheme clusters in the input string as a vector of string slices.
- truncate_
by_ width - Re-exports: Primary public API Truncates a string by display width while preserving grapheme cluster boundaries.