Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Thai combining marks cause width miscalculation in modern terminals (Kitty, Ghostty)

Đang mở
#3,957 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
cli

Hướng nghiên cứu

Start by inspecting the Thai ranges in _cell_widths.py, then run the supplied Console, Table, and cell_len reproduction with the listed Thai strings. Done means the reported Thai cell lengths match the terminal widths in Kitty and Ghostty, with table columns no longer misaligned.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Problem

Thai combining marks (vowels and tone marks) are marked as zero-width in CELL_WIDTHS, following Unicode's Mn (Nonspacing Mark) classification. However, modern terminal emulators (tested: Kitty, Ghostty) render Thai text with these characters taking visible width, causing table columns and other layouts to misalign.

Reproduction

from rich.console import Console
from rich.table import Table
from rich.cells import cell_len

console = Console()
table = Table(title='Thai Text Width Test')
table.add_column('Text', width=10)
table.add_column('cell_len')

for text in ['สวัสดี', 'น้ำ', 'กรุงเทพ']:
    table.add_row(text, str(cell_len(text)))

console.print(table)

Width Analysis

Text Codepoints Combining marks Rich cell_len Terminal width
สวัสดี 6 2 4 6
น้ำ 3 1 2 3
กรุงเทพ 7 1 6 7

The discrepancy equals the number of combining marks — terminals render each Thai codepoint as width 1.

Affected Ranges in CELL_WIDTHS

Range Characters Unicode Category
U+0E31 ั Mn (sara am vowel)
U+0E34-U+0E3A ิ ี ึ ื ุ ู ฺ Mn (vowel signs)
U+0E47-U+0E4E ็ ่ ้ ๊ ๋ ์ ํ ๎ Mn (tone marks)

Environment

  • Rich: 13.7.1
  • Python: 3.14.2
  • Terminals tested:
    • Kitty 0.45.0 — affected
    • Ghostty 1.2.3 — affected
  • Platform: macOS

Proposed Fix

Change Thai combining mark ranges from width 0 to width 1 in _cell_widths.py. This matches actual terminal rendering behavior for Thai script.

Ngôn ngữ chính
Python
Star
57.5k
Fork
2.4k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Textualize/rich

Tất cả issue của Textualize/rich

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.