From 6d1cdb5f28bcba84ea39acbd9c355155029230e5 Mon Sep 17 00:00:00 2001 From: RageGen Date: Tue, 24 Nov 2026 10:02:47 +0300 Subject: [PATCH] fix: preserve console font size suffixes --- archinstall/lib/locale/utils.py | 2 +- tests/test_console_fonts.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/test_console_fonts.py diff --git a/archinstall/lib/locale/utils.py b/archinstall/lib/locale/utils.py index 39393c75d7..7003474fbd 100644 --- a/archinstall/lib/locale/utils.py +++ b/archinstall/lib/locale/utils.py @@ -32,7 +32,7 @@ def list_locales() -> list[str]: @lru_cache def list_console_fonts() -> list[str]: directory = Path('/usr/share/kbd/consolefonts') - fonts = {path.name.split('.')[0] for path in directory.glob('*.gz')} + fonts = {path.stem.removesuffix('.psfu').removesuffix('.psf').removesuffix('.fnt').removesuffix('.cp') for path in directory.glob('*.gz')} return sorted(fonts) diff --git a/tests/test_console_fonts.py b/tests/test_console_fonts.py new file mode 100644 index 0000000000..a21e41bd33 --- /dev/null +++ b/tests/test_console_fonts.py @@ -0,0 +1,24 @@ +from pathlib import Path +from unittest.mock import patch + +from archinstall.lib.locale.utils import list_console_fonts + + +def test_list_console_fonts_preserves_font_sizes(tmp_path: Path) -> None: + for name in ['cp857.08.gz', 'cp857.14.gz', 'cp857.16.gz', 'iso01.08.gz', 'iso01.16.gz']: + (tmp_path / name).touch() + + with patch('archinstall.lib.locale.utils.Path', return_value=tmp_path): + fonts = list_console_fonts.__wrapped__() + + assert fonts == ['cp857.08', 'cp857.14', 'cp857.16', 'iso01.08', 'iso01.16'] + + +def test_list_console_fonts_strips_format_extensions(tmp_path: Path) -> None: + for name in ['default8x16.psfu.gz', 'default8x16.psf.gz', 'arm8.fnt.gz', '161.cp.gz', 'Mik_8x16.gz', 'README']: + (tmp_path / name).touch() + + with patch('archinstall.lib.locale.utils.Path', return_value=tmp_path): + fonts = list_console_fonts.__wrapped__() + + assert fonts == ['161', 'Mik_8x16', 'arm8', 'default8x16']