From 73ee8232e7ea72a90130ccf67d8ffefd4122e9f4 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sat, 24 Jan 2026 21:33:23 +0000 Subject: [PATCH 1/2] fix fonts --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- rich/cells.py | 2 +- tests/test_cells.py | 6 ++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cd1275bf6..1472ac84c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [14.3.1] - 2025-01-24 + +### Fixed + +- Fixed characters out of unicode range reporting a cell size if 0 + ## [14.3.0] - 2025-01-24 ### Fixed @@ -2177,6 +2183,7 @@ Major version bump for a breaking change to `Text.stylize signature`, which corr - First official release, API still to be stabilized +[14.3.1]: https://github.com/textualize/rich/compare/v14.3.0...v14.3.1 [14.3.0]: https://github.com/textualize/rich/compare/v14.2.0...v14.3.0 [14.2.0]: https://github.com/textualize/rich/compare/v14.1.0...v14.2.0 [14.1.0]: https://github.com/textualize/rich/compare/v14.0.0...v14.1.0 diff --git a/pyproject.toml b/pyproject.toml index 1cd6a50c30..267fdc91c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "rich" homepage = "https://github.com/Textualize/rich" documentation = "https://rich.readthedocs.io/en/latest/" -version = "14.3.0" +version = "14.3.1" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" authors = ["Will McGugan "] license = "MIT" diff --git a/rich/cells.py b/rich/cells.py index 4429790957..15fe7b65cd 100644 --- a/rich/cells.py +++ b/rich/cells.py @@ -57,7 +57,7 @@ def get_character_cell_size(character: str, unicode_version: str = "auto") -> in codepoint = ord(character) table = load_cell_table(unicode_version).widths if codepoint > table[-1][1]: - return 0 + return 1 lower_bound = 0 upper_bound = len(table) - 1 index = (lower_bound + upper_bound) // 2 diff --git a/tests/test_cells.py b/tests/test_cells.py index 84ff55f88f..b0f96978a8 100644 --- a/tests/test_cells.py +++ b/tests/test_cells.py @@ -181,3 +181,9 @@ def test_split_graphemes( assert cell_len(text) == expected_cell_length assert spans == expected_spans assert cell_length == expected_cell_length + + +def test_nerd_font(): + """Regression test for https://github.com/Textualize/rich/issues/3943""" + # Not allocated by unicode, but used by nerd fonts + assert cell_len("\U000f024d") == 1 From 2e5a5dad304b59d75aa4b4ed6cae031693e3615e Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sat, 24 Jan 2026 21:34:12 +0000 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1472ac84c3..6f3029d4ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fixed characters out of unicode range reporting a cell size if 0 +- Fixed characters out of unicode range reporting a cell size if 0 https://github.com/Textualize/rich/pull/3944 ## [14.3.0] - 2025-01-24