I have today successfully managed to add custom fonts to the OnlyOffice in my Cryptpad instance.
For future reference, this is what I did:
Before you begin, please create a backup of your Cryptpad instance, just to be sure.
Note: I run a Yunohost installation of Cryptpad, so it could be that some of the files are stored in a bit different locations than usual. Nonetheless, the steps described here should, I feel, give you a pretty good idea of what to do.
Note: the v7
bit in the file paths might be different for you, depending on what the most recent OnlyOffice installation is in your Cryptpad instance.
I cloned the nextcloud 'documentserver_community' github repo and ran make:
git clone https://github.com/nextcloud/documentserver_community.git
cd documentserver_community
make
Make did complain about something, but when I looked for the magic script needed, it was there.
If you have now an executable at 3rdparty/onlyoffice/documentserver/tools/allfontsgen
, you can get your fonts compiled.
Now, you place all the fonts that your OnlyOffice should have in a folder.
For example, what I did on my personal computer was:
cd 3rdparty/onlyoffice/documentserver/server/tools
mkdir fonts
And on my server:
sudo tar -czvf OnlyOfficeFonts.tar.gz /var/www/cryptpad/www/common/onlyoffice/dist/v7/fonts/*
And then again on my own PC:
cd fonts
scp USER@SERVER:~/OnlyOfficeFonts.tar.gz fonts.tar.gz
tar -xzvf fonts.tar.gz
And then I copied all the additional fonts I wished to have to documentserver_community/3rdparty/onlyoffice/documentserver/server/tools/fonts/var/www/cryptpad/www/common/onlyoffice/dist/v7/fonts/
(Yes, that is awfully long, and unnecessarily so. But this is how I did it.)
It is very important to also move all additional fonts to your server:
scp var/www/cryptpad/www/common/onlyoffice/dist/v7/fonts/YOUR_FONT.ttf USER@SERVER:~/
And then on the server:
sudo cp YOUR_FONT.ttf /var/www/cryptpad/www/common/onlyoffice/dist/v7/fonts/
(And I also did the next command, though possible it will work without it as well.)
sudo cp YOUR_FONT.ttf /usr/share/fonts/truetype/
Now, you're ready to compile the fonts for use in your Cryptpad's OnlyOffice.
On my own PC I ran:
cd ..
./allfontsgen \
--input="fonts/var/www/cryptpad/www/common/onlyoffice/dist/v7/fonts" \
--allfonts-web="../../sdkjs/common/AllFonts.js" \
--allfonts="../FileConverter/bin/AllFonts.js" \
--images="../../sdkjs/common/Images" \
--output-web="../../fonts" \
--selection="../FileConverter/bin/font_selection.bin"
Then I had to edit one of the two AllFonts.js
files, for else it would not work.
Make sure, with your favourite text editor, to find+replace all fonts filenames so as to remove the path, in ../FileConverter/bin/AllFonts.js
, as it will not work when the path remains. (And it is, indeed, not in your original AllFonts.js
file on the server either.)
Once you've done that, it's time to move things to your server!
The most obvious step might be this one:
scp ../FileConverter/bin/AllFonts.js USER@SERVER:~/
But please remember to also do the following step, as otherwise you'll have the fonts, but not the font name preview things.
cd ../../sdkjs/common/Images
tar -czvf FontImages.tar.gz fonts*
scp FontImages.tar.gz USER@SERVER:~/
And then finally on your server:
tar -xzvf FontImages.tar.gz
sudo cp fonts_thumbnail* /var/www/cryptpad/www/common/onlyoffice/dist/v7/sdkjs/common/Images/
sudo cp AllFonts.js /var/www/cryptpad/www/common/onlyoffice/dist/v7/sdkjs/common/
And that's it! Now you can use your custom fonts.