1
0
mirror of https://github.com/octoleo/plantuml-server.git synced 2024-12-21 16:29:03 +00:00
plantuml-server/examples/additional-fonts
Florian f6fa448ed8 add doc: how to add fonts
Add an example about how to add additional fonts indside the PlantUML docker container.
2023-05-26 10:19:40 +02:00
..
docker-compose.yml add doc: how to add fonts 2023-05-26 10:19:40 +02:00
README.md add doc: how to add fonts 2023-05-26 10:19:40 +02:00

Additional fonts inside the PlantUML docker container

It is possible to make additional fonts available to PlantUML by mapping them via a volume within the docker container.

Since the base image from the docker container is using Ubuntu, fonts can easily be provided by just adding them somewhere inside the ~/.local/share/fonts directory.

Tipp: to not overwrite the container fonts add the additional files inside an own sub-folder, e.g., custom or host.

In the following you can find an example how to provide all fonts of your host machine in the PlantUML docker container for Jetty and Tomcat.

Jetty

In the case of the Jetty docker container the home directory is /var/lib/jetty.

services:
  plantuml-server:
    image: plantuml/plantuml-server:jetty
    container_name: plantuml-server
    ports:
      - "80:8080"
    environment:
      - TZ=Europe/Berlin
      - BASE_URL=plantuml
    volumes:
      - /usr/share/fonts:/var/lib/jetty/.local/share/fonts/host:ro

Tomcat

In the case of the Tomcat docker container the home directory is /root.
Yes, the tomcat container is running as root which is basically a really bad idea w.r.t. security. Create a pull request and maintain it if you want to change that.

services:
  plantuml-server:
    image: plantuml/plantuml-server:tomcat
    container_name: plantuml-server
    ports:
      - "80:8080"
    environment:
      - TZ=Europe/Berlin
      - BASE_URL=plantuml
    volumes:
      - /usr/share/fonts:/root/.local/share/fonts/host:ro

Verification

The following command will print a list of all available fonts inside the docker container:

docker exec -it plantuml-server fc-list

To find a special font add a grep filter to the command:

docker exec -it plantuml-server fc-list | grep "<name-of-font>"

Naturally, it is also possible to check this via PlantUML itself by rendering the following diagram:

@startuml
listfonts
@enduml

Note: If you have added a lot of fonts: (a) this diagram may take a few seconds to generate, and (b) eventually the PNG image may be clipped. To avoid the latter, render the diagram as an SVG image.