runefix-core
๐ฏ A Rust core library that fixes terminal and Markdown misalignment caused by CJK and emoji widths.
English | ็ฎไฝไธญๆ | ๆฅๆฌ่ช
โจ Overview
runefix-core
is a Unicode-based display width engine that provides precise character width calculation, designed for:
- Terminal CLI alignment
- Markdown table rendering
- TUI layout engines
- Rich text editor rendering
Its goal is to solve a decades-long problem: misaligned characters in terminal and UI environments due to inconsistent Unicode width handling. This includes:
- CJK characters (Chinese, Japanese, Korean), Kana, and Hangul syllables
- Emoji (base, composite, and flag sequences)
- Fullwidth punctuation and multilingual symbols
- Grapheme cluster boundary cases
โ Key Features
- โ Accurate width detection for emoji, CJK, Hangul, Kana, and fullwidth symbols
- โ Full support for grapheme clusters (emoji composition, regional indicators)
- โ Zero dependencies, minimal API, compatible with any terminal or UI renderer
- โ Fully reproducible datasets, powered by char-table
- โ Language bindings planned for JS / Python / Go and more
๐ Quick Example
use RuneDisplayWidth;
๐ท Real-World Examples
For a full demo of grapheme-aware alignment and terminal behavior, see examples/text_align.rs.
It showcases:
- Naive centering using
.chars().count()
โ - Fixed centering using
runefix_core::RuneDisplayWidth
โ - Screenshot comparisons across terminals
๐ Read more in examples/README.md
๐ฆ Installation
Add the following to your Cargo.toml
:
# Stable release (recommended)
= "0.1"
See crates.io for the latest version.
๐ Use Cases
- ๐ฅ๏ธ Terminal alignment (CLI box drawing, tables)
- ๐งพ Markdown renderers (accurate width handling in table cells)
- ๐ TUI layout engines (React-style terminal UIs)
- ๐ Editors and terminal emulators (accurate text wrapping)
- ๐งฉ Width testing tools, playgrounds, and visualization platforms
๐ Dataset Sources
This crate relies on structured, versioned datasets from char-table, including:
emoji_base.json
,emoji_zwj.json
cjk_unified.json
,japanese_kana.json
,korean_syllables.json
fullwidth_variants.json
,fullwidth_punctuations.json
All datasets are reproducible, regularly updated, and aligned with the latest Unicode releases.
๐ ๏ธ Project Status
Module | Status |
---|---|
CJK width detection | โ Completed |
Emoji width support | โ Completed |
Grapheme cluster | โ Completed |
๐ CHANGELOG
See CHANGELOG.md for version history.
๐ License
MIT OR Apache-2.0
ยฉ 2025 Pokeya Z. Chen / Runefix Labs
๐ฃ Project Affiliation
This project is maintained by the runefix-labs organization. It serves as the core engine for the runefix suite โ a multi-language, cross-platform solution for Unicode width handling.
๐ Contact
GitHub: github.com/runefix-labs
Author: pokeyaro
Email: pokeya.mystic@gmail.com