alfio-event / alf.io

alf.io - The open source ticket reservation system for conferences, trade shows, workshops, meetups
https://alf.io
GNU General Public License v3.0
1.43k stars 352 forks source link

Installing Custom Fonts in Docker for PDF Templates #1406

Open justusweigmann opened 2 months ago

justusweigmann commented 2 months ago

Hey all, I noticed that the PDF Template function is referring in the font face to a specific .ttf font file: @font-face { font-family: 'DejaVu Sans'; src: url('alfio-internal:/DejaVuSans.ttf'); }

Could anyone tell me how I can install a new font in the Docker container? That way, we can use our company's house font.

syjer commented 2 months ago

hi @justusweigmann , at the moment, the only way would be to add the fonts in https://github.com/alfio-event/alf.io/tree/main/src/main/resources/alfio/font and build from scratch. As a security measure, we don't allow arbitrary fonts to be added at runtime.

But we are open to find a good way to open this possibility. (for example mounting a docker volume with the fonts?)

justusweigmann commented 2 months ago

Hey @syjer,

Thank you for the quick response. I'll look into building Alf.io from scratch myself then.

I'm currently using the Docker container, and as you describe the manual font process, theoretically the volume mapping to the fonts folder should look like this: volumes: ./host-mounting/fonts:/src/main/resources/alfio/font

And when restarting the container, theoretically the new data in the folder should be available in Alf.io. I will try this option as well; maybe that's the fix.

justusweigmann commented 2 months ago

So I got the following logs after mapping the Docker Volume Folder to the Host: 2024-09-16T11:54:07.832Z WARN 1 --- [Alf.io] [tp1619842305-55] o.a.p.p.f.FileSystemFontProvider : 22 new fonts found, font cache will be re-built 2024-09-16T11:54:07.832Z WARN 1 --- [Alf.io] [tp1619842305-55] o.a.p.p.f.FileSystemFontProvider : Building on-disk font cache, this may take a while 2024-09-16T11:54:08.328Z WARN 1 --- [Alf.io] [tp1619842305-55] o.a.p.p.f.FileSystemFontProvider : Finished building on-disk font cache, found 22 fonts

Problem now is that Alf.io is not able to use the fonts: java.lang.IllegalStateException: java.io.FileNotFoundException: class path resource [alfio/font/IBM_Plex_Sans/IBMPlexSans-Regular.ttf] cannot be opened because it does not exist

I also tried: java.io.FileNotFoundException: class path resource [alfio/font/IBMPlexSans-Regular.ttf] cannot be opened because it does not exist

I think that this is only a permission issue. Should be an easy fix.