How to add fonts to Collabora (and perhaps OpenOffice)?

NethServer Version: 7.7
Module: nethserver-collabora

Collabora is installed and working fine in Nextcloud and has been for some time. However, I’m wanting to add a few new fonts to match some work I’m doing on my desktop machine. This page:


says to put them in a directory in /usr/share/fonts/ and then run fc-cache /path/to/directory/. Well and good, and sounds easy enough. So I put a few font files there (both .ttf and .otf), and ran that command, which ran without error or output. But when I open a document in Nextcloud/Collabora, I don’t see those fonts available to me. No doubt I’m missing something simple–any ideas?

From here

Restart loolwsd.service and the fonts are available.

But there are few more steps before fc-cache

1 Like

Well, yes and no. As far as I can see, the “few more steps” all deal with installing certain fonts (specifically, the MS core fonts and MS vista fonts, which amounts to putting them somewhere under /usr/share/fonts), while I’m more interested in taking fonts from my desktop computer and putting them on my Neth box so I can use them in Collabora.

But in any event, restarting loolwsd.service only gets me part of the way there. The fonts do appear in the fonts menu (which they didn’t before), and I can select them, but they don’t actually appear. If I select one of them and start typing, nothing appears. If I type some text, highlight it, and change the font to one of those added, the text disappears.

Thinking it might be an issue with the fonts I copied, I tried with one of the MS core fonts and with one of the MS vista fonts, with the same results in both cases.

Tried it a few days ago. Same problem (0-width text present but not shown, like it disappeared), didn’t find a solution.

Good to know I’m not alone, at least.

Did anybody managed Collabora installations not made on NethServer?

Interestingly, I pulled up a document today, and the previously-added fonts were now not only present in the fonts list (they were there previously), but they actually worked. To my knowledge, I haven’t changed anything else since I posted previously in this thread–perhaps there was some other caching that needed to clear itself out?

Did you installed updates and/or rebooted the server during last few days?

Definitely haven’t rebooted, but I have installed some updates in the interim.

I’m not part of the nethserver community really but I do run a “custom” Collabora Nextcloud setup of my own. Everything manually installed (not using Docker).

I ran into the exact same issue as above, copied fonts to: /usr/share/fonts/truetype, fc-cache, restart loolwsd and - the fonts show up and are selectable in the list for LibreOffice but are “invisible” when displayed on the document.

I discovered an actual repeatable solution though which makes the fonts work with a few extra steps, no waiting on an update or server reboots or anything.

So … here’s what I’ve done:
Installed five additional custom fonts.
Four of which are copied straight from the Windows 10 Fonts folder (Arial, Calibri, Consolas, Verdana)
One from Google Fonts (Roboto); downloaded directly from fonts.google(.com) as a zip file

Uploaded them all to the server manually (SFTP) and placed each font set in their own respective folders - ensuring all were world readable;

ls -al /usr/share/fonts/truetype/
total 40
drwxr-xr-x 9 root root 4096 Apr 14 14:41 .
drwxr-xr-x 4 root root 4096 Apr 14 14:33 …
drwxr-xr-x 2 root root 4096 Apr 14 14:34 arial
drwxr-xr-x 2 root root 4096 Apr 14 14:34 calibri
drwxr-xr-x 2 root root 4096 Apr 14 14:34 consolas
drwxr-xr-x 2 root root 4096 Apr 14 14:34 dejavu
drwxr-xr-x 2 root root 4096 Apr 14 14:34 lato
drwxr-xr-x 2 root root 4096 Apr 14 14:34 roboto
-rw-r–r-- 1 root root 36 Dec 18 10:05 .uuid
drwxr-xr-x 2 root root 4096 Apr 14 14:34 verdana

There is only 2 additional steps which seem to be required over those mentioned in previous posts to make these work, which I can only assume some of which occurred automatically with @danb35 when he installed updates.

Copy all fonts to the following folders
/usr/share/fonts/truetype
/opt/lool/systemplate/usr/share/fonts/truetype

Run
fc-cache

Now this next command - you have to make sure that you adjust the version number to the one matching your Collabora installation for this folder: /opt/collaboraoffice6.2

Run AS ROOT (or just execute the actual command as the lool user)
su lool --shell=/bin/sh -c "loolwsd-systemplate-setup /opt/lool/systemplate /opt/collaboraoffice6.2 >/dev/null 2>&1"

I suspect the above command is really the one you need over all else as this is automatically executed each time you install system updates using APT.

And finally
systemctl restart loolwsd

Hopefully this works as well for others as it did for me.

2 Likes

My apologies, I wrote fc-update in the above post but it should be fc-cache as mentioned earlier.

I don’t seem to be allowed to edit the above post any further perhaps too much time has passed.

It works for me! I am adding new fonts to NextCloud Office ( Collabora Online - Built-in CODE Server ) as I found that it does not support Chinese characters originally.

My settings are: Ubuntu, Apache 2.4.52, MySQL 8.0, PHP 8.1 ( LAMP, non docker environment )

Here’s how i made it:

  1. Put fonts files in any path that are listed in /etc/fonts/fonts.conf (i.e. /usr/share/fonts/truetype by default)
  2. Run fc-cache -f -v
  3. Supposingly, you should see some output like this:
    /usr/share/fonts: caching, new cache contents: 0 fonts, 1 dirs
    /usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 2 dirs
    /usr/share/fonts/truetype/dfkai-sb: caching, new cache contents: 6 fonts, 0 dirs
    /usr/share/fonts/truetype/ dfkai-sb : caching, new cache contents: 1 fonts, 0 dirs
    /usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
    /home//.local/share/fonts: skipping, no such directory
    /home//.fonts: skipping, no such directory
    /usr/share/fonts/truetype: skipping, looped directory detected
    /usr/share/fonts/truetype/dejavu: skipping, looped directory detected
    /usr/share/fonts/truetype/ dfkai-sb : skipping, looped directory detected
    /var/cache/fontconfig: not cleaning unwritable cache directory
    /home//.cache/fontconfig: cleaning cache directory
    /home//.fontconfig: not cleaning non-existent cache directory
    fc-cache: succeeded

dfkai-sb is the font i added.
The above command do the caching job and shows the output.

  1. It is done.
  2. Back to the Nextcloud Office Editor ( Collabora Online - Built-in CODE Server ), you can see the font you added listed in the font selector. ( If not, try restart the apache service by sudo systemctl reload apache or even sudo systemctl restart apache and reboot your server. For me, I cannot see it after these all because I am using Cloudflare, so after these, turn on Development Mode in Cloudflare (only if you are using Cloudflare caching) to see effects immediately. )

This should help those using Collabora with Nextcloud in LAMP environment.

1 Like