render user text with noto sans cjk and fit it properly

Draw text that users write with Noto Sans CJK Bold so Chinese, Japanese,
Korean, Cyrillic and Greek no longer show up as boxes. It replaces
DejaVu Sans and Impact, and Comic Sans everywhere but the CS2 bingo.
The Dockerfile makes the font available to Graphviz for /mbti.

put_text_in_box now finds the largest font size where the text, wrapped
to the box's pixel width, fits, and centers the drawn text. Long texts
used to overflow and single letters were pushed out of their box.
Words are only split when keeping them whole would halve the size.

Long crab rave texts shrink to fit the video instead of going past its
edges, and the divider line is a bit longer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
leanderandClaude Opus 5.5 committed 2026-11-01 20:28:00 +01:00
1 parent 14c3caedf5
commit 154d4de881
10 files changed
+243 -95

No files matched your search

+3
View File
@@ -16,6 +16,9 @@ RUN .venv/bin/python -m nltk.downloader -d /usr/local/share/nltk_data stopwords
COPY . .
# Let Graphviz find the bundled font for text in other scripts, like CJK
RUN mkdir -p /usr/local/share/fonts && ln -s /app/src/assets/fonts/NotoSansCJK-Bold.ttc /usr/local/share/fonts/
ENV PATH="/app/.venv/bin:$PATH"
VOLUME /app/logs