Change default font terminal in DietPI

Hi, following the thread to enable the output to Pimoroni HyperPixel display, I have a trouble with the font.

Since my (PADD) script looks better with Terminus font, but I don’t think this font exists in dietpi, I’ve already tried to change the etc/default/console-setup with:

CHARMAP=”UTF-8"
CODESET=”guess”
FONTFACE="Terminus"
FONTSIZE=”8x18"

But this is the same as use “guess”, no difference. So I don’t think this font is installed.

Now the font is

But should be:

Is there a way to install and use it?

EDIT: I fount the fonts in usr/share/consolefonts, and the Termius font is there, why the system don’t use it? Maybe there’s something to change in /usr/share/console-setup/console-setup ? Now it’s

ACTIVE_CONSOLES=guess
CHARMAP=guess
CODESET=guess
FONTFACE=TerminusBold
FONTSIZE=16

Thanks!

sudo dpkg-reconfigure console-setup

Thanks for the reply, unfortunately the command doesn’t work on dietpi

root@DietPi:~# sudo dpkg-reconfigure console-setup
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

By the way I tried to change all the fonts from the /etc/console-default (all the Uni1 fonts, the others can’t work), but there’s something weird because the best looking font is the Uni2-Fixed15 but on Raspbian it was different, I don’t know what is the trouble :thinking:

Since in DietPI all the fonts are not cached/loaded like in raspbian, in order to change the font you have to edit the /etc/console-setup/cached_setup_font.sh and change the two /usr/share/consolefonts/Uni2-Fixed16.psf.gz with your font, ie: /usr/share/consolefonts/Uni2-TerminusBold16.psf.gz.

And obviously you have to copy (duplicate) the selected font from /etc/consolefonts to /etc/console-setup/

This is the default file.

#!/bin/sh

setfont '/usr/share/consolefonts/Uni2-Fixed16.psf.gz' 

if ls /dev/fb* >/dev/null 2>/dev/null; then
    for i in /dev/vcs[0-9]*; do
        { :
            setfont '/usr/share/consolefonts/Uni2-Fixed16.psf.gz' 
        } < /dev/tty${i#/dev/vcs} > /dev/tty${i#/dev/vcs}
    done
fi

mkdir -p /run/console-setup
> /run/console-setup/font-loaded
for i in /dev/vcs[0-9]*; do
    { :
printf '\033%%G' 
    } < /dev/tty${i#/dev/vcs} > /dev/tty${i#/dev/vcs}
done

The unusual fact is that changing to 8x18 fontsize in Raspian look totally different from DietPi, as you can see from my pictures in the first post.

I’m struggling to find out what’s the trouble, or in the end I will keep this font and edit my custo PADD script in order to fit more information. Because there’s more space, 4 more lines in height, but fits perfect in width, this is the weird thing! If a font is bigger or smaller (the height) it should be also longer or shorter. Not here, or I don’t understand what’s going on in dietPI :thinking:

At the end DietPi is not an own OS. For Raspberry Pi device we use Raspberry OS as base line. Just we are running with a reduced amount of apt packages installed. That’s why it is diet :slight_smile:

Maybe there are packages missing that would be available on plain RPI OS by default.

I’m not aware that DietPi is doing anything specific on fonts for CLI. But this doesn’t mean anything :rofl:
MichaIng any ideas?

Ok, when you make changes manually in console-setup you have to update initramfs, but this command is also not available in Dietpi. :rofl:
I have no more idea.

when you make changes manually in console-setup you have to update initramfs, but this command is also not available in Dietpi

If needed update-initramfs is part of initramfs-tools package and can be installed easily

apt install initramfs-tools

Maybe than it is just easier to install console-setup and have a nice interactive config tool? :slight_smile:

I never tried to change font’s on my system as all of them are headless :smiley:

I can install what I want, but if I can do it manually I prefer (in order to keep going on the diet :rofl: ) but if I manually change the font, as I described in the post above, and nothing change, then… I don’t know what else I can do :slight_smile:

For example, it’s weird that if I change the

FONTSIZE=”anything"

in console-setup, nothing is different. Probably dietpi keep only one font (with one size) cached.

Not a big problem but my goal would be to understand how it works, in order to change it (also because I’m curious of the difference with raspbian). Or I add some lines of info to my custom padd script with other system/hardware details! But I don’t know what to add, there’s almost every info of the RPI/PiHole :thinking:

ok I found a statement that console-setup have been superseded on systemd operating systems. Therefore it is not working anymore. tty - Can I change the font of the text-mode console? - Unix & Linux Stack Exchange

But there is quite a simple way to change fonts. Just add following to your .bashrc located on root user home directory

/usr/bin/setfont /usr/share/consolefonts/Uni2-TerminusBold16.psf.gz

I did a test with Uni2-TerminusBold28x14.psf.gz


and Uni2-TerminusBold16.psf.gz


There you can see how font size is changing after reboot.

I love the proof with the ruler :smiley:

I tried without but it was not that visible on the pictures. :rofl:

Ahah “banana for scala” :rofl:

Thanks a lot, as soon as I’m at home I’ll try. (Well I can do it also remotely via VPN but then it will be hard to see the change on the Raspberry PI display from outside home :smiley: )

I just tested, for me editing .bashrc didn’t work. I changed the font using the /etc/console-setup/cached_setup_font.sh but works only if I use Uni2-Fixed15.psf.gz.

Maybe you have a different option in /defaults/console-setup, I don’t know.

The font (15px) looks perfect but I have to repeat again that the font and size looks the same, but the overall height is different from raspbian, now it’s smaller! I can fill it with other info on the rpi/pihole, but I have to spend the time to do it again :slight_smile: and I’m curious because I really can’t understand what and where is the difference! :thinking:

Terminus15pt (aka fixed fir “guess” in console-setup on dietpi

and Terminus8x18 in raspbian, the font is the same but the overall height is different :face_with_raised_eyebrow:

Maybe is something related to the display, looks like now it is running at its default resolution (800x480px) and instead on my previous config (Raspbian Buster) it was running something like 800x400px. The font was also less sharp. Now it’s okay but I have to add the info to fill the empty space in the display :smiley:

Suggestion? What info/stat/data can I add?

Joulinar

Okay I’ve filled the empty space with some useful info provided by DietPi (as space used, processes, packages, etc…)

Weird thing is that when I launch padd (./padd.sh) for one second I have two weird error that I can’t understand :thinking:

./padd.sh: line 24: warning: command substitution: ignored null byte in input
sed: can't read else: No such file or directory

line 24 is:

model=$((cat /proc/device-tree/model) | awk '{print $1$2, $3, $4, $5, $6$7}')

What error is this?

And the sed error also is weird because I don’t have used the sed command :face_with_raised_eyebrow: maybe something related to the other error. But the script works fine, I’m happy with how it looks

Another useful command (to output the power of DietPI :sunglasses: ) would be the

Boot duration systemd-analyze | mawk ‘{print $(NF-1)" "$NF;exit}’

But if I launch it locally (via ssh) to test it, works perfect, If I insert the coda as a variable in the PADD script, it shows nothing.

If you want to try I’ve uploaded the script here: https://dsc.cloud/40973c/padd.sh

Thanks for your help in these thread! I solved all my inital troubles with DietPi :sunglasses:

not sure if I missunderstood. But I did not used /etc/console-setup/cached_setup_font.sh at all. I just copied the line into .bashrc. That’s it.

One more idea about the information shown. Why not showing the information about DietPi updates being available. Or apt package updates? Similar to how we show it on the banner?

Yes I understood that you used the bashrc way but for me didn’t work. With the bashrc I can change only the size of the font but if I change to other fonts, the same font is displayed, only with some weird characters.

I think it could be due to the console-setup settings. Try to change to Terminus8x18 like I had on raspbian: nothing change for me.

Anyway this Terminus 15px looks very nice! It’s a bit small but I can display some other info in PADD and it’s also sharper.

About the idea of display DietPI info, yeah, nice idea, I haven’t thought of it!

The only downside is that if other people that don’t have DietPI, can’t use it. Now it’s more universal for everyone!

PS: do you know about the errors? And why the boot time of DietPI doesn’t work on the external display but works on local terminal?

I think also show the boot time it’s interesting, because it’s very low compared to raspbian, and it’s a universal command that works also on raspbian!

as Stated already, DietPi is a Raspberry OS. And systemd-analyze is working same way :wink:

root@DietPi3:~# systemd-analyze | mawk '{print $(NF-1)" "$NF;exit}'
= 11.276s
root@DietPi3:~#

I did not had time to look into your scripts. Need to say, I’m not a bash coding expect. This is more the domain of or (single) developer MichaIng.

As said this code works fine via SSH but if I include in my script, that runs locally on the RPi and displays the output to the attached monitor, it’s blank/empty!

But maybe could be because it needs root privileges to run (and I launch my script as normal user), I’ll investigate in it later.

hmm I tried with a really stupid user called demo.

$ whoami
demo
$
$
$ systemd-analyze | mawk '{print $(NF-1)" "$NF;exit}'
= 11.276s
$

Doesn’t looks like systemd-analyze require root privileges. :thinking: