@@ -41,16 +41,6 @@ def json(self) -> str:
4141_ENV_FONT = os .environ .get ('FONT' )
4242
4343
44- class _FontState :
45- def __init__ (self ) -> None :
46- self .font_backup : Path | None = None
47- self .cmap_backup : Path | None = None
48- self .using_env_font : bool = False
49-
50-
51- _font_state = _FontState ()
52-
53-
5444def _set_console_font (font_name : str | None ) -> bool :
5545 """
5646 Set the console font via setfont.
@@ -75,37 +65,40 @@ def _save_console_font() -> None:
7565 cmap_fd , cmap_path = tempfile .mkstemp (prefix = 'archinstall_cmap_' )
7666 os .close (font_fd )
7767 os .close (cmap_fd )
78- _font_state . font_backup = Path (font_path )
79- _font_state . cmap_backup = Path (cmap_path )
80- SysCommand (f'setfont -O { _font_state . font_backup } -om { _font_state . cmap_backup } ' )
68+ translation_handler . _font_backup = Path (font_path )
69+ translation_handler . _cmap_backup = Path (cmap_path )
70+ SysCommand (f'setfont -O { translation_handler . _font_backup } -om { translation_handler . _cmap_backup } ' )
8171 except SysCallError as err :
8272 debug (f'Failed to save console font: { err } ' )
83- _font_state . font_backup = None
84- _font_state . cmap_backup = None
73+ translation_handler . _font_backup = None
74+ translation_handler . _cmap_backup = None
8575
8676
8777def _restore_console_font () -> None :
8878 """Restore console font (with unicode map) and console map from backup."""
89- if _font_state . font_backup is None or not _font_state . font_backup .exists ():
79+ if translation_handler . _font_backup is None or not translation_handler . _font_backup .exists ():
9080 return
9181
92- args = str (_font_state . font_backup )
93- if _font_state . cmap_backup is not None and _font_state . cmap_backup .exists ():
94- args += f' -m { _font_state . cmap_backup } '
82+ args = str (translation_handler . _font_backup )
83+ if translation_handler . _cmap_backup is not None and translation_handler . _cmap_backup .exists ():
84+ args += f' -m { translation_handler . _cmap_backup } '
9585 _set_console_font (args )
9686
97- _font_state . font_backup .unlink (missing_ok = True )
98- _font_state . font_backup = None
99- if _font_state . cmap_backup is not None :
100- _font_state . cmap_backup .unlink (missing_ok = True )
101- _font_state . cmap_backup = None
87+ translation_handler . _font_backup .unlink (missing_ok = True )
88+ translation_handler . _font_backup = None
89+ if translation_handler . _cmap_backup is not None :
90+ translation_handler . _cmap_backup .unlink (missing_ok = True )
91+ translation_handler . _cmap_backup = None
10292
10393
10494class TranslationHandler :
10595 def __init__ (self ) -> None :
10696 self ._base_pot = 'base.pot'
10797 self ._languages = 'languages.json'
10898 self ._active_language : Language | None = None
99+ self ._font_backup : Path | None = None
100+ self ._cmap_backup : Path | None = None
101+ self ._using_env_font : bool = False
109102
110103 self ._total_messages = self ._get_total_active_messages ()
111104 self ._translated_languages = self ._get_translations ()
@@ -213,7 +206,7 @@ def activate(self, language: Language, set_font: bool = True) -> None:
213206 language .translation .install ()
214207 self ._active_language = language
215208
216- if set_font and not _font_state . using_env_font :
209+ if set_font and not self . _using_env_font :
217210 _set_console_font (language .console_font )
218211
219212 def _get_locales_dir (self ) -> Path :
0 commit comments