Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vconsole font selection to cover more langs #3180

Merged
merged 1 commit into from Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion pyanaconda/modules/localization/installation.py
Expand Up @@ -24,6 +24,7 @@
from pyanaconda.core.constants import DEFAULT_VC_FONT
from pyanaconda.modules.localization.localed import get_missing_keyboard_configuration
from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.localization import get_locale_console_fonts

log = get_module_logger(__name__)

Expand Down Expand Up @@ -194,12 +195,19 @@ def write_vc_configuration(vc_keymap, root):
try:
fpath = os.path.normpath(root + VC_CONF_FILE_PATH)

# "eurlatgr" may not be the best choice for all the languages,
# for example, Russian, Urdu, Serbian, Sindhi and a few more.
# refer: https://bugzilla.redhat.com/show_bug.cgi?id=1919486
# assuming that LANG is set by now.
vc_fonts = get_locale_console_fonts(os.environ["LANG"])
vc_font = vc_fonts[0] if vc_fonts else DEFAULT_VC_FONT

with open(fpath, "w") as fobj:
fobj.write('KEYMAP="%s"\n' % vc_keymap)

# systemd now defaults to a font that cannot display non-ascii
# characters, so we have to tell it to use a better one
fobj.write('FONT="%s"\n' % DEFAULT_VC_FONT)
fobj.write('FONT="%s"\n' % vc_font)

except IOError as ioerr:
msg = "Cannot write vconsole configuration file: {}".format(ioerr.strerror)
Expand Down
Expand Up @@ -691,6 +691,22 @@ def write_vc_configuration_test(self):
'KEYMAP="{}"\nFONT="{}"\n'.format(vc_keymap, DEFAULT_VC_FONT)
)

@patch.dict(os.environ, {"LANG": "ru_RU.UTF-8"})
def write_vc_configuration_env_test(self):
"""Test write_vc_configuration function for latarcyr console font."""
with tempfile.TemporaryDirectory() as root:
vc_keymap = "ru"
vc_font = "latarcyrheb-sun16"
os.mkdir(os.path.join(root, "etc"))
write_vc_configuration(vc_keymap, root)
fpath = os.path.normpath(root + VC_CONF_FILE_PATH)
# Check the result.
with open(fpath) as f:
self.assertEqual(
f.read(),
'KEYMAP="{}"\nFONT="{}"\n'.format(vc_keymap, vc_font)
)

def write_x_configuration_test(self):
"""Test write_x_configuration_test."""
localed_wrapper = Mock()
Expand Down