Script to conveniently package fonts


#1

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:

#!/bin/sh
#
# Create a package from fonts in $sourceDir

sourceDir=/HiQ-Data/fonts

destBase=$(mktemp -d)
destDir=$destBase/data/fonts

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

echo
echo "Increase version/provides and update fonts list in the description."
echo
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 @ mail.com>"
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
AurulentSans
Avalon
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
#2

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


#3

There is a yab sw for that.


#4

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


#5

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


#6

There’s a tracker add-on for installing .ttf or .otf font files:

It’s called fontinstaller by Giovanni Mugnai available on BeSly repo: http://www.software.besly.de/index.php?system=haikupm