Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing Custom Fonts in Docker for PDF Templates #1406

Open
justusweigmann opened this issue Sep 15, 2024 · 3 comments
Open

Installing Custom Fonts in Docker for PDF Templates #1406

justusweigmann opened this issue Sep 15, 2024 · 3 comments
Labels

Comments

@justusweigmann
Copy link

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
Copy link
Member

syjer commented Sep 15, 2024

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?)

@syjer syjer added the question label Sep 15, 2024
@justusweigmann
Copy link
Author

justusweigmann commented Sep 16, 2024

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
Copy link
Author

justusweigmann commented Sep 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants