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:

#!/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…

1 Like

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:

2 Likes

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

1 Like

Is ‘fontinstaller’ only 32-bit app?

I cannot seem to find it in Haiku Depot where I am running a 64-bit Haiku.

Ask them :slight_smile:

Hello. Doing a little reasearch, I found this post: Font installer Tracker Addon

As the author said in the post, there is no 64 bit version. I didn’t found the sources to try to recompile it for 64 bit, but in the same post he said that the FontInstaller are based in this app:

Maybe we can try to recompile TrackerScript for 64 bit version, and using it as a replacement.

@un_spacyar, @extrowerk

Well…darn! Such a complicated process just to install my personal fonts… :wink:

Well, I will try the script above once I figure what it is doing…

The article, Font installer Tracker Addon, is a nice article. If I was a developer, I would play with it.

Segue, is C++ and Python the only supported mainstream programming languages for Haiku?
I saw some articles about JavaScript–but it seems it is not close yet.

I downloaded the books for 'Programming Be Operating System ’ & ‘Learning to program with Haiku’ via BeSly web-site. Any books for Python on Haiku for a complete newbie?

Thanks for looking!!

Well, that process is only if you want to add a font as a package. :slight_smile:

Another way is copying your needed .ttf files to the /fonts/ folder available in /home/config/non-packaged/data/

Both ways are valid. The only difference is that using the second one there could be some app that doesn’t recognize them. Don’t remember exactly which one is.

Thanks…I read about that option. But I have over 350 True Type fonts I need in the system fonts areas because Wonderbrush app will not find them according to @humdinger statements. The other 300+ can over to /home/config/non-packaged/data/ directory as you stated and I will test that LibreOffice and other text processors can find them. So far nothing is being picked up from the /home/config/settings/font directory.

Still trying out things and working through issues to get my Haiku system the way I want it…:wink:

Thanks!!

You can make a hpkg with your fonst (private use), so you can install them if you need it.

Here you can use my hpkg creator.

Http://Software.besly de

Or check the open_sans recipe, there are multiple fonts installed with that package, rename it, change the sources accordingly, build with haikuporter and you should be good to go (only takes some time to edit it for +300 fonts) :smile:

@Begasus

Thank you…but I am not sure what you mean by a ‘recipe’. I have seen the word ‘haikuporter’ around the forums but I have not had the chance to learn about it yet. So I do not know what that does yet. Soon…I will learn what it is and how to use it.

I will refer back to this when the time comes. :wink:

No problem, once you start to try out just ring the bell :wink:

Czy jest szansa by pakiety miały nazwy w moim języku?
powiedzmy tak
OPIS_pl_PL w utf8
Podsumowanie jak i skrócony opis.

Mógłbym zorientować się co zawiera paczka.
Jesli już jest to jak to się robi?

—automatic translate–
Is there a chance that the packages will have names in my language?
let’s say yes
OPIS_en_US in utf8
Summary and short description.

I could find out what the package contains.
If this is already how it is done?

Somebody would have to translate all the descriptions. We got sadly no manpower for that.

This has been fixed and merged in July.
@stippi: You think a new mini-update of WonderBrush was possible?
If you don’ t want to make a official point release, I could just point the current v2.1.2 recipe to the latest git revision hash and up the recipe’s revision for a rebuild.

You mean /boot/system/non-packaged/data/fonts ?

Not sure what’s the problem in using the script of this topic to get a proper HPKG…
After copying your fonts into the folder, it’s just a double-click and updating Revision and optionally the Description in the up-popping editor window.
With only a bit of websearching and experimenting, even non-bash scripters should be able to automate this even further, by doing the Revision increase and adding all font names in the folder as Description automatically.

C’mon, guys, a bit more hacker’s spirit! :smile:

1 Like

No…I meant “/home/config/settings/font” directory since that is what I remember from days of yore. That is where user fonts would go if you did not want them in the system fonts directory in BeOS/ZetaOS where I expected the same behavior in Haiku.

Anyway, I learnt about the directory “boot/system/non-packaged/data/fonts”–or the non-BeOS/ZetaOS system directory, which I recently now understand why that exists today. Once I copied my other 1100 fonts in there…LibreOffice and other apps now see my fonts. [Something that I had to learn about…]

Your statement “Not sure what’s the problem in using the script of this topic to get a proper HPKG…” can be a very complex task for the non-programmer type user. I still have not attempted it since I clearly do not understand the HPKG process. Although, I am very familiar to the Package Builder software in BeOS/ZetaOS…this new package system in Haiku–not so much. More to learn for me later…as I learn to use the HPKGCreator software, it would make more sense to me then.

Of course, my WonderBrush v2.1.2-8 still does not see my fonts. I need them to be installed into the system fonts areas for WonderBrush to see the fonts. But I will wait until your changes are implemented…