Installing new fonts in Collabora

I installed collabora on a debian stretch instance without docker.
After some struggles I got it to work.
https://help.nextcloud.com/t/native-debian-9-collabora-package-does-not-install-correctly/21191/13
and
https://help.nextcloud.com/t/tools-language-for-is-showing-code-instead-of-options/22213/4
did the trick.
Still fonts used on the users laptops and desktops (microsoft) using LibreOffice and some MSOffice are not available.
A possibile solution in https://help.nextcloud.com/t/i-want-to-prevent-design-collapse-by-font-in-collabora/22676/7 did not work.
(Same I found in https://central.owncloud.org/t/howto-install-collabora-online-on-ubuntu-16-04-without-docker/3844/9)

The way to add fonts that did work I found here: https://www.pcworld.com/article/2863497/how-to-install-microsoft-fonts-in-linux-office-suites.html.
It is explained for Ubuntu, but also works in debian.

For the core MS fonts:

sudo apt-get install ttf-mscorefonts-installer

You may be asked to accept the license agreement, i was not asked.

They end up in /usr/share/fonts/truetype/msttcorefonts

Next is to install the clear types such as calibri.

This is a bit different but can be done with the vista fonts installer script.
Make sure you have the appropriate permissions.
Create a .font folder as the script needs that.

mkdir .font
wget -qO- http://plasmasturm.org/code/vistafonts-installer/vistafonts-installer | bash

all new fonts are installed in the .font folder

in /usr/share/fonts/truetype create folder msttvistafonts

copy all fonts from the .fonts folder to /usr/share/fonts/truetype/msttvistafonts
change the ownerships to the same as that in the other fonts if needed.

Now run

fc-cache

Restart loolwsd.service and the fonts are available.

1 Like

I am reviving this old topic as it is applicable to ā€œInstalling new fonts in Collaboraā€ and I could not find a solution to my problem on the NextCloud forums.

I attempted to add my own fonts on a non-docker server as well and ran into an issue similar to that is mentioned here (also described in the next paragraph).

Where fonts were displayed in the drop down list of fonts to choose form in Collabora, but they didnā€™t actually appear on the document, even though the text was still there it was not actually visible.

It took me a few hours but I solved it and I posted my solution at the above link, but I will also post it in here since I have nothing to do with the nethserver community and I originally searched for the answer here but could not find it.

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 like so, ensuring all were world readable:

ls -al /usr/share/fonts/truetype/
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
drwxr-xr-x 2 root root 4096 Apr 14 14:34 verdana

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"

And finally
systemctl restart loolwsd

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

Thanks @Sylice for this ā€œupdateā€! You mention:

I get no fc-update command on my Ubuntu server, hereā€™s what fc commands I find:

fc-cache (1) - build font information cache files
fc-cat (1) - read font information cache files
fc-list (1) - list available fonts
fc-match (1) - match available fonts
fc-pattern (1) - parse and show pattern
fc-query (1) - query font files
fc-scan (1) - scan font files or directories
fc-validate (1) - validate font files

Did you mean fc-cache?

Hi, another problem is all the undesirable fonts (such as Noto* for instance) are back when you upgrade CODEā€¦

My apologies youā€™re right itā€™s fc-cache, not fc-update. I will update that original post above.

As to getting rid of existing fonts and not allowing them to come back, I do not not how to help with that.

I did a crontab scheduled bash script to remove every night the list of fonts I donā€™t need in /opt/collaboraoffice6.2/share/fonts/truetype, followed by fc-cache and a systemctl loolwsd restart

:crazy_face:

I followed both @pieter and @Sylice instructions but I cannot even get the new fonts to show up in the list.
I installed msttcorefonts and msttvistafonts in both /usr/share/fonts/truetype/ and /opt/lool/systemplate/usr/share/fonts/truetype.
I run fc-cache and restarted loolwsd.service.
I did all with root user (not Nextcloud user) and the permissions for every folder are ```
drwxr-xr-x 2 root root 4096.

What could I have missed? Could it be I need to change permissions to include Nextcloud user, or maybe www-data?

1 Like

I did install this on a NON docker setup. The fonts are installed on the machine to be available to all.
For that, the fonts need the same permissions and ownership as all other already existing fonts available.

For running applications to accept, you need fc-cache and apps (loolwsd) to be restarted.

Is there any update to this tutorial? I performed all steps, renaming some of the ā€œloolwsdā€ to ā€œcoolwsdā€, but Fonts are not displayed proper.

1 Like

Have you resolved this yet? Iā€™ve followed the steps above renaming for cool where needed but the font basically is blank while the text is there. For example, I can see the data in a spreadsheet formula bar but it is blank in the cell.

Nevermindā€¦ I missed a stepā€¦

Iā€™m on Ubuntu 20.04 with Collabora 22.05

I copied the ttf to both:
/usr/share/fonts/truetype
/opt/cool/systemplate/usr/share/fonts/truetype (thought I had it here but went back and did not)

Then ran the fc-cache
Then ran the systemctl restart coolwsd

I did run the ā€˜coolwsd-systemplate-setup /opt/cool/systemplate /opt/collaboraoffice >/dev/null 2>&1ā€™ as root but not sure if this was necessary since I had to move the ttf to the folder I missed, re-ran the cache and restart and then it worked.

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.

Hi there, after running fc-cache and before the coolwsd restart, the template update mentioned by @Sylice was achieved in my case by running:

coolconfig update-system-template

Without it the font files werenā€™t added to the chroot template and documents with the newly added fonts would display contents apparently blank/missing.

None of the above works. Please make fonts easier to upload and implement in the built in CODE server! This is unacceptable. We should be able to simply upload them and they just work. What is all this business with coolconfig and whatnot. No. That is not ok. It needs to upload and just work.

coolconfig isnt even implemented in some docker containers. It is not acceptable to rely on such an archaic solution.

Who is in charge of the UX???

Hello, This may be an old topic but after some updates the fonts stopped working on my server. im running image: collabora/code:latest and i have set the

volumes:
- /usr/share/fonts/truetype/:/usr/share/fonts/truetype:ro

the font names are visible but not usable they display blank space.
anny ides?

After somewhat digging i found that actually there is a simpler way to this:

ā€“o:remote_font_config.url=https://nextcloud.yourdomanin.com/apps/richdocuments/settings/fonts.json

1 Like

Would you be able to explain this more? How would this make fonts available to a docker container? Where would this line go in the docker compose file? Are you saying fonts.json is an alternative to adding the volume? Thanks