SetFont() on Linux
SetFont() on Linux
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
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
- airsoftsoftwair
- Posts: 5834
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: SetFont() on Linux
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
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:
produces the output
The font I did install:
/usr/share/fonts - so this one can't work in any case?
Ralf
Examples:
Part of the output:fc-list | grep -i "ubuntu"
Running this with the Interpreter:/usr/share/fonts/truetype/ubuntu/Ubuntu-R.ttf: Ubuntu:style=Regular
Code: Select all
t = GetAvailableFonts()
DebugPrint(ListItems(t),"Fonts")
SetFont(#SERIF, 20)
SetFont("Ubuntu Regular",24)and then the error0 Fonts
I tried without the "Regular", but the same effect.Cannot open font Ubuntu Regular with size 24!
File: SetFontTest2.hws (current line: 4 - In function: SetFont)
The font I did install:
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 infc-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
/usr/share/fonts - so this one can't work in any case?
Ralf
- airsoftsoftwair
- Posts: 5834
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: SetFont() on Linux
[/code]
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$)
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
Here it is: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$)
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
That works:airsoftsoftwair wrote: ↑Sat Oct 15, 2022 7:24 pmThat 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?
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)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
I have tried
Code: Select all
AddFontPath("/usr/share/fonts/truetype/")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
Code: Select all
AddFontPath("/usr/share/fonts/truetype/ubuntu")Re: SetFont() on Linux
In the meantime I did some reading. How about checking if fontconfig is available and getting the fonts that way too?
- airsoftsoftwair
- Posts: 5834
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: SetFont() on Linux
Ok, that explains everything. Hollywood doesn't recurse into subdirectories. Will fix that.
Hollywood has its own fontconfigFlinx 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?
- airsoftsoftwair
- Posts: 5834
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: SetFont() on Linux
Code: Select all
- Fix [Linux]: Font directories are now scanned recursively because newer Linuxes often store fonts in
subdirectories inside the system font directories