From 9454f43eba3a65cf1aaeb2fb448f958abcce1a41 Mon Sep 17 00:00:00 2001 From: Luca <102960244+Luca-Timo@users.noreply.github.com> Date: Wed, 3 Jun 2026 16:01:07 +0200 Subject: [PATCH] fix(pdf): install fonts so SVG logo text rasterises correctly The runtime image (node:22-alpine) shipped without any fonts, so when sharp/librsvg rasterised an SVG logo containing live for the CRM PDFs, the vector artwork drew but the text rendered as tofu boxes - a 'corrupted' logo on invoices/quotes. - Add fontconfig + DejaVu/Liberation (broad Unicode fallback) and refresh the font cache. - Register picpeak's own bundled brand fonts (assets/fonts//*.ttf - the same files PDFKit and the web UI already use) with fontconfig via a conf.d entry + fc-cache, so the logo's text renders in its ACTUAL brand typeface rather than a generic fallback. --- backend/Dockerfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index e8e66a74..7192433d 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -43,7 +43,16 @@ RUN npm install -g npm@10 # `@ffmpeg-installer/ffmpeg` binary is glibc-built and (a) doesn't reliably # run on Alpine and (b) only includes ffmpeg, not ffprobe (which the video # pipeline calls via fluent-ffmpeg.ffprobe()). -RUN apk add --no-cache dumb-init postgresql-client ffmpeg su-exec +# fontconfig is required so `sharp` (librsvg) can rasterise SVG logos that +# contain live for the CRM PDFs. Without any font installed, librsvg +# renders text as tofu boxes (□) while the vector artwork still draws — i.e. +# a "corrupted" logo on invoices/quotes. DejaVu/Liberation provide a broad +# Unicode fallback; picpeak's own brand fonts (assets/fonts/, the same files +# PDFKit + the web UI use) are registered with fontconfig further down so the +# logo's text renders in its actual typeface, not a fallback. +RUN apk add --no-cache dumb-init postgresql-client ffmpeg su-exec \ + fontconfig ttf-dejavu ttf-liberation && \ + fc-cache -f # Create non-root user RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001 @@ -55,6 +64,14 @@ COPY --chown=nodejs:nodejs . . # Ensure all source files are readable and wait script is executable RUN chmod -R a+r /app && chmod +x wait-for-db.sh +# Register picpeak's bundled brand fonts (assets/fonts//*.ttf — the +# same files PDFKit and the web UI use) with fontconfig, so when sharp/librsvg +# rasterises an SVG logo its renders in the actual brand typeface +# rather than a DejaVu/Liberation fallback. fontconfig indexes by each font's +# internal family name and recurses into the per-family subdirectories. +RUN printf '\n\n\n /app/assets/fonts\n\n' > /etc/fonts/conf.d/99-picpeak-fonts.conf && \ + fc-cache -f /app/assets/fonts + # Create necessary directories RUN mkdir -p storage/events/active storage/events/archived storage/thumbnails data logs && \ chown -R nodejs:nodejs storage data logs