Script to conveniently package fonts


Hi there!

Normally, putting fonts into either /system/non-packaged/data/fonts/ or ~/config/non-packaged/data/fonts/ is easy enough a procedure to make new fonts available. Sadly, Haiku’s main graphics package “WonderBrush” doesn’t care about the “non-packaged” hierarchy that was introduced with package management. The solution is to create a package of your fonts, which will appear in the usual /system/data/fonts/ hierarchy that WonderBrush expects.

To make this more convenient (esp. if you add/remove fonts more often), I created a simple script that does the work for me:

# Create a package from fonts in $sourceDir


destBase=$(mktemp -d)

mkdir -p ${destDir}/otfonts ${destDir}/ttfonts
cp -a ${sourceDir}/*.otf ${destDir}/otfonts
cp -a ${sourceDir}/*.ttf ${destDir}/ttfonts

echo "Increase version/provides and update fonts list in the description."
lpe ${sourceDir}/.PackageInfo

cp -a ${sourceDir}/.PackageInfo $destBase

package create -C  $destBase ~/Desktop/myfonts.hpkg
open ~/Desktop/myfonts.hpkg

rm -rf $destBase
# rm ~/Desktop/myfonts.hpkg

You just have to adjust the “$sourceDir” variable to point to the folder with your fonts.
You also need a “.PackageInfo” file inside that fonts folder. Mine looks like this:

name		myfonts
version		1.0-1
architecture	any

packager	"Humdinger <humaddress @>"
vendor		"Humdinger"

copyrights	"2016 Various artists"
licenses	"Artistic"

provides {
		myfonts = 1.0-1

summary		"A couple of fonts in a package"
description	"Abusive Pencil
ACaslon Ornaments
AG Benguiat Cyr
Baskerville BT
...and so on and so forth"

Before packaging it all, this “.PackageInfo” file opens in the Pe editor. Now you can increase the version of your package (don’t forget to keep “version” and “provides” in sync) and add/remove fonts from the description if you want to.

Finally, the package is created on the desktop and is opened in HaikuDepot, ready to be installed. Installing system fonts make the user interface a bit unresponsive for a few seconds. Nothing to worry about.

The last line in the script is commented out to keep the created package on the desktop; maybe you’d like to back it up or something. Just remove the “#” in front of the last line to have it removed automatically.

NOTE: Packaging fonts like this is very convenient, but should only be used for your private use. Fonts come with all kinds of different licenses that such a packaging doesn’t care about…

Great new default Desktop font!
IBM Plex font
How do i add fonts

Looking forward to when you build a GUI client for your script :stuck_out_tongue_winking_eye:


There is a yab sw for that.


You can use mktemp instead of randomID=$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32).


Neat! I’ll use that then… Much less geeky, though. :slight_smile: