Skip to content

Commit

Permalink
Merge pull request #3180 from sundeep-anand/vc-font
Browse files Browse the repository at this point in the history
vconsole font selection to cover more langs
  • Loading branch information
M4rtinK committed Feb 22, 2021
2 parents b79a8bd + 59e2cca commit a59ff6d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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

0 comments on commit a59ff6d

Please sign in to comment.