Best Place to Auto-Set Local Linux TTY Console Font?

Kernel, Main, Utilities & Applications, Miscellaneous Devices.
vanfanel
Posts: 191
Joined: Sun May 24, 2020 6:53 pm
Has thanked: 14 times
Been thanked: 26 times

Best Place to Auto-Set Local Linux TTY Console Font?

Unread post 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.

Flandango
Core Developer
Posts: 480
Joined: Wed May 26, 2021 9:35 pm
Has thanked: 66 times
Been thanked: 388 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post 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):

Code: Select all

::sysinit:/bin/setfont

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.

rhester72
Top Contributor
Posts: 1471
Joined: Thu Jun 11, 2020 2:31 am
Has thanked: 17 times
Been thanked: 246 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post by rhester72 »

Rename from _user-startup.sh to user-startup.sh (no leading underscore). The former is just a template.

vanfanel
Posts: 191
Joined: Sun May 24, 2020 6:53 pm
Has thanked: 14 times
Been thanked: 26 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post 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)

rhester72
Top Contributor
Posts: 1471
Joined: Thu Jun 11, 2020 2:31 am
Has thanked: 17 times
Been thanked: 246 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post 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?

rhester72
Top Contributor
Posts: 1471
Joined: Thu Jun 11, 2020 2:31 am
Has thanked: 17 times
Been thanked: 246 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post 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.

Flandango
Core Developer
Posts: 480
Joined: Wed May 26, 2021 9:35 pm
Has thanked: 66 times
Been thanked: 388 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post 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

rhester72
Top Contributor
Posts: 1471
Joined: Thu Jun 11, 2020 2:31 am
Has thanked: 17 times
Been thanked: 246 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post 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!

Flandango
Core Developer
Posts: 480
Joined: Wed May 26, 2021 9:35 pm
Has thanked: 66 times
Been thanked: 388 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post by Flandango »

You may need to have it do a reboot, but in my case/situation, it took immediate effect.

rhester72
Top Contributor
Posts: 1471
Joined: Thu Jun 11, 2020 2:31 am
Has thanked: 17 times
Been thanked: 246 times

Re: Best Place to Auto-Set Local Linux TTY Console Font?

Unread post 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!

Post Reply