Page 1 of 1
Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Tue Feb 18, 2025 7:34 pm
by vanfanel
Hi there,
So far, I've added this to /etc/profile:
Code: Select all
setfont /usr/share/consolefonts/Lat2-Terminus24x12.psf.gz
It works, but doesn't kick-in until I've log in, and logging in with the default tiny font on a 1080p video mode can be the hard part.
So, where should I set the font so it's set before the F9 login prompt appears?
Thanks!
EDIT: Also tried /media/fat/linux/_user-startup.sh but adding it there doesn't have any effect.
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Tue Feb 18, 2025 7:56 pm
by Flandango
vanfanel wrote: ↑Tue Feb 18, 2025 7:34 pm
Hi there,
So far, I've added this to /etc/profile:
Code: Select all
setfont /usr/share/consolefonts/Lat2-Terminus24x12.psf.gz
It works, but doesn't kick-in until I've log in, and logging in with the default tiny font on a 1080p video mode can be the hard part.
So, where should I set the font so it's set before the F9 login prompt appears?
Thanks!
EDIT: Also tried /media/fat/linux/_user-startup.sh but adding it there doesn't have any effect.
Edit the /etc/inittab file and change this line (at about line 32):
to
Code: Select all
::sysinit:/bin/setfont /usr/share/consolefonts/Lat2-Terminus24x12.psf.gz
I am not sure if this will persist through a linux update. In the case it doesn't, you may need to create a script in _user-startup.sh to check and modify the file accordingly.
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Tue Feb 18, 2025 8:08 pm
by rhester72
Rename from _user-startup.sh to user-startup.sh (no leading underscore). The former is just a template.
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Tue Feb 18, 2025 8:47 pm
by vanfanel
@Flandango Many thanks! That works perfectly! But I fear it won't survive a system update, since it would overwrite /media/fat/linux/linux.img, thus overwritting everyting in /etc since that's part of the embedded system...
Maybe what rhester72 proposed would survive a system update, but even if I move /media/fat/linux/_user-startup.sh to /media/fat/linux/user-startup.sh and do setfont /usr/share/consolefonts/Lat2-TerminusBold24x12.psf.gz there, it doesn't have any effect.
(Yes, the font is on my system and it works if done on /etc/inittab)
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Tue Feb 18, 2025 9:58 pm
by rhester72
If you redirect stdout and stderr like this in user-startup.sh:
setfont /usr/share/consolefonts/Lat2-TerminusBold24x12.psf.gz &> /tmp/result.txt
and then cat /tmp/result.txt after fully booted up, what do you see?
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Tue Feb 18, 2025 10:37 pm
by rhester72
Never mind, already did it, and am EXTREMELY mystified:
Code: Select all
/root# tail -1 /media/fat/linux/user-startup.sh
setfont -v /usr/share/consolefonts/cp866-8x8.psf.gz &> /tmp/result.txt
/root# cat /tmp/result.txt
setfont: INFO setfont.c:161 do_loadfont: Loading 256-char 8x8 font from file /usr/share/consolefonts/cp866-8x8.psf.gz
setfont: INFO setfont.c:248 do_loadtable: Loading Unicode mapping table...
/root# showconsolefont -iv
Character count: 512
Font width : 8
Font height : 16
/root# setfont /usr/share/consolefonts/cp866-8x8.psf.gz
/root# showconsolefont -iv
Character count: 256
Font width : 8
Font height : 8
user-startup.sh must be being executed before something else critical-path is loaded, but I have no idea what.
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Tue Feb 18, 2025 11:06 pm
by Flandango
Add this to your user-startup.sh script (or create a new shell script in a place like /Scripts and then have user-startup.sh call it)...
Code: Select all
ISFONTSET=`grep -c "::sysinit:/bin/setfont /usr/share/consolefonts/Lat2-Terminus24x12.psf.gz" /etc/inittab`
if [[ "$ISFONTSET" == "0" ]]; then
sed -i "s/::sysinit:\/bin\/setfont$/::sysinit:\/bin\/setfont \/usr\/share\/consolefonts\/Lat2-Terminus24x12.psf.gz/" /etc/inittab
fi
This should check on each startup if that setting is in /etc/inittab...if not, it will add it
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Wed Feb 19, 2025 12:37 pm
by rhester72
I might even add a reboot in that if block so it'll automatically recycle and set it without user intervention, but good call @Flandango!
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Wed Feb 19, 2025 1:52 pm
by Flandango
You may need to have it do a reboot, but in my case/situation, it took immediate effect.
Re: Best Place to Auto-Set Local Linux TTY Console Font?
Posted: Wed Feb 19, 2025 1:55 pm
by rhester72
That actually makes sense - we know that user_startup.sh is firing 'too early' for setfont, which by definition means inittab happens later. Good point!