Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion archinstall/lib/locale/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
24 changes: 24 additions & 0 deletions tests/test_console_fonts.py
Original file line number Diff line number Diff line change
@@ -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']