Page 1 of 1
SetFont() on Linux
Posted: Wed Oct 12, 2022 6:06 pm
by Flinx
Hello,
just noticed that
SetFont() doesn't work on Linux, and
GetAvailableFonts() also returns an empty list. I probably missed something basic. Is there any preparation needed?
Ralf
Re: SetFont() on Linux
Posted: Wed Oct 12, 2022 9:34 pm
by airsoftsoftwair
Hmm, where are the fonts stored on your Linux system? Hollywood checks these paths:
Code: Select all
/usr/share/fonts/truetype
/usr/local/share/fonts/truetype
/usr/share/X11/fonts/TT
Re: SetFont() on Linux
Posted: Thu Oct 13, 2022 12:16 pm
by Flinx
This is a Mint 20.3 (Cinnamon 5.2.7), but upgraded from an earlier version. The fonts are in /usr/share/fonts/truetype/, but the one that I tried to install with the font-viewer is in ~/.local/share/fonts/
Examples:
fc-list | grep -i "ubuntu"
Part of the output:
/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf: Ubuntu:style=Regular
Running this with the Interpreter:
Code: Select all
t = GetAvailableFonts()
DebugPrint(ListItems(t),"Fonts")
SetFont(#SERIF, 20)
SetFont("Ubuntu Regular",24)
produces the output
0 Fonts
and then the error
Cannot open font Ubuntu Regular with size 24!
File: SetFontTest2.hws (current line: 4 - In function: SetFont)
I tried without the "Regular", but the same effect.
The font I did install:
fc-list | grep -i "albertus"
/home/ralf/.local/share/fonts/911Fonts.com_AlbertusExtraBoldRegular__-_911fonts.com_fonts_qoqk.ttf: Albertus Extra Bold:style=Standard,Normal,Obyčejné,Regular,Normali,Normál,Normale,Standaard,Normalny,Обычный,Orta
Yesterday before asking I tried with a Rocky Linux live ISO too (because I have no working Raspberry here at the moment), there are the fonts in
/usr/share/fonts - so this one can't work in any case?
Ralf
Re: SetFont() on Linux
Posted: Sat Oct 15, 2022 7:24 pm
by airsoftsoftwair
[/code]
Flinx wrote: ↑Thu Oct 13, 2022 12:16 pm
This is a Mint 20.3 (Cinnamon 5.2.7), but upgraded from an earlier version. The fonts are in /usr/share/fonts/truetype/
That is weird. Hollywood scans /usr/share/fonts/truetype so it should find the fonts. Can you post the output of this code?
Code: Select all
For s$ In DirectoryItems("/usr/share/fonts/truetype") Do DebugPrint(s$)
Flinx wrote: ↑Thu Oct 13, 2022 12:16 pm
~/.local/share/fonts/
That is a non-standard path. Have you tried adding that path to Hollywood's font search path using
AddFontPath() and then try if
GetAvailableFonts() can find the font?
Re: SetFont() on Linux
Posted: Sat Oct 15, 2022 8:46 pm
by Flinx
airsoftsoftwair wrote: ↑Sat Oct 15, 2022 7:24 pm
That is weird. Hollywood scans /usr/share/fonts/truetype so it should find the fonts. Can you post the output of this code?
Code: Select all
For s$ In DirectoryItems("/usr/share/fonts/truetype") Do DebugPrint(s$)
Here it is:
Code: Select all
Opening script SetFontTest3.hws...done
Compiling script...done
Preparing display...done
And Action!
fonts-deva-extra
tibetan-machine
ttf-khmeros-core
fonts-guru-extra
lohit-assamese
lohit-devanagari
lohit-oriya
fonts-orya-extra
fonts-telu-extra
Gubbi
dejavu
tlwg
lohit-tamil-classical
fonts-kalapi
samyak
Navilu
ubuntu
abyssinica
padauk
liberation
Gargi
kacst
Sahadeva
lohit-malayalam
liberation2
lohit-tamil
sinhala
Sarai
lohit-punjabi
pagul
malayalam
lohit-telugu
fonts-beng-extra
Nakula
freefont
fonts-yrsa-rasa
openoffice
fonts-gujr-extra
lohit-gujarati
lohit-kannada
noto
lao
samyak-fonts
lohit-bengali
.uuid
kacst-one
droid
airsoftsoftwair wrote: ↑Sat Oct 15, 2022 7:24 pm
Flinx wrote: ↑Thu Oct 13, 2022 12:16 pm
~/.local/share/fonts/
That is a non-standard path. Have you tried adding that path to Hollywood's font search path using
AddFontPath() and then try if
GetAvailableFonts() can find the font?
That works:
Code: Select all
AddFontPath("/home/ralf/.local/share/fonts")
t = GetAvailableFonts()
DebugPrint(ListItems(t),"Fonts")
For Local k = 0 To ListItems(t) - 1
DebugPrint("Family:", t[k].Family, "Weight:", t[k].Weight,
"Slant:", t[k].Slant, "Bitmap:", t[k].Bitmap)
Next
SetFont("Albertus Extra Bold",40)
print("Hallo")
wait(300)
produces this output
Code: Select all
Opening script SetFontTest2.hws...done
Compiling script...done
Preparing display...done
And Action!
1 Fonts
Family: Albertus Extra Bold Weight: 80 Slant: 0 Bitmap: 0
and then shows the "Hallo" rendered with this font.
I have tried
Code: Select all
AddFontPath("/usr/share/fonts/truetype/")
but still 0 Fonts from
GetAvailableFonts().
Then I did move the Albertus ttf file to /usr/share/fonts/truetype/, there
GetAvailableFonts() finds it.
The difference to the other fonts is that they are in subdirectories:
Code: Select all
ls -ld /usr/share/fonts/truetype/ubuntu/
drwxr-xr-x 2 root root 4096 Aug 24 2021 /usr/share/fonts/truetype/ubuntu/
ls -l /usr/share/fonts/truetype/ubuntu/
insgesamt 4308
-rw-r--r-- 1 root root 356980 Jul 10 2015 Ubuntu-BI.ttf
-rw-r--r-- 1 root root 333612 Jul 10 2015 Ubuntu-B.ttf
-rw-r--r-- 1 root root 350444 Jul 10 2015 Ubuntu-C.ttf
-rw-r--r-- 1 root root 409608 Jul 10 2015 Ubuntu-LI.ttf
-rw-r--r-- 1 root root 415552 Jul 10 2015 Ubuntu-L.ttf
-rw-r--r-- 1 root root 366992 Jul 10 2015 Ubuntu-MI.ttf
-rw-r--r-- 1 root root 216208 Sep 26 2011 UbuntuMono-BI.ttf
-rw-r--r-- 1 root root 191400 Sep 26 2011 UbuntuMono-B.ttf
-rw-r--r-- 1 root root 210216 Sep 26 2011 UbuntuMono-RI.ttf
-rw-r--r-- 1 root root 205748 Sep 26 2011 UbuntuMono-R.ttf
-rw-r--r-- 1 root root 341324 Jul 10 2015 Ubuntu-M.ttf
-rw-r--r-- 1 root root 386440 Jul 10 2015 Ubuntu-RI.ttf
-rw-r--r-- 1 root root 353824 Jul 10 2015 Ubuntu-R.ttf
-rw-r--r-- 1 root root 240020 Mär 8 2019 Ubuntu-Th.ttf
I now tried
Code: Select all
AddFontPath("/usr/share/fonts/truetype/ubuntu")
and got the 14 Ubuntu variants.
Re: SetFont() on Linux
Posted: Mon Oct 17, 2022 10:20 am
by Flinx
In the meantime I did some reading. How about checking if
fontconfig is available and getting the fonts that way too?
Re: SetFont() on Linux
Posted: Mon Oct 17, 2022 7:55 pm
by airsoftsoftwair
Flinx wrote: ↑Sat Oct 15, 2022 8:46 pm
The difference to the other fonts is that they are in subdirectories:
Ok, that explains everything. Hollywood doesn't recurse into subdirectories. Will fix that.
Flinx wrote: ↑Mon Oct 17, 2022 10:20 am
In the meantime I did some reading. How about checking if
fontconfig is available and getting the fonts that way too?
Hollywood has its own fontconfig

I'm not sure if it's possible to get the path to the TTF/OTF files or individual TTFs inside TTC files. I think there was some reason why I didn't use fontconfig...
Re: SetFont() on Linux
Posted: Mon Jan 02, 2023 10:17 pm
by airsoftsoftwair
Code: Select all
- Fix [Linux]: Font directories are now scanned recursively because newer Linuxes often store fonts in
subdirectories inside the system font directories