Files
DolanandClaude Opus 5.5 4f9348521d fix(layout): make a paragraph's last line as tall as its text, and draw Calibri Light in Carlito in CI's LibreOffice (#3593)
* fix(layout): make a paragraph's last line as tall as its text, not its mark

The layout made the last line of every paragraph at least as tall as the
paragraph's mark. Word and LibreOffice don't: a line of 8-point text in a
paragraph whose mark is 11 points is 8 points tall, as a document of
probes saved as a PDF from Word 16 for Mac and laid out by LibreOffice
26.8 showed. Text given a smaller size than its style's, as a TextRun's
size does, was laid out too tall, which put a heading of the
text-and-spacing demo on the page after Word's.

The mark now only sets the height of a line with no text on it, such as
an empty paragraph's, or a page break's at the end of a paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NijyutGmb3bNR3dNRWJken

* ci: draw Calibri Light in Carlito in the shape demos' LibreOffice

LibreOffice has no font for Calibri Light, the heading font of Office's
theme and of docx's default heading styles, and drew it in Noto Serif,
whose lines are 12% taller. So the layout comparison checked docx/layout,
which measures Calibri Light as Calibri, against headings taller than
Word's: Calibri Light is as tall as Calibri. A fontconfig alias makes
LibreOffice draw it in Carlito, as wide and tall as Calibri.

The title of charts-in-templates, in the template's heading font, is now
drawn in Carlito, so its reference image is drawn again. The other 30
pages don't change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NijyutGmb3bNR3dNRWJken

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 15:01:00 +01:00

34 lines
1.9 KiB
Docker

# The environment the shape demos are drawn in for the visual regression tests.
#
# LibreOffice and fonts change how pages are drawn, so everything is pinned: the base image by its digest, Debian's
# packages to the snapshot of the archive the base image was made from, and LibreOffice to a release from The
# Document Foundation's archive. The reference images in ./references are drawn in this image, on linux/amd64, so
# renders from CI and from a Mac or Windows machine match.
#
# Build: docker build --platform linux/amd64 -t docx-shape-renderer scripts/shape-demos
FROM debian:trixie-slim@sha256:a99cfc517144bc59b1978475ec53b46ecabec7e43635402ee5b77cc54cd1b20a
ARG LIBREOFFICE_VERSION=26.8.0.3
# Fonts with the same widths as Times New Roman, Arial, Calibri and Cambria, and a fallback for everything else
RUN sed -i -e '/^URIs:/d' -e 's|^# \(http://snapshot.debian.org/.*\)|URIs: \1|' /etc/apt/sources.list.d/debian.sources \
&& apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install -y --no-install-recommends \
ca-certificates curl poppler-utils \
fontconfig fonts-liberation2 fonts-crosextra-carlito fonts-crosextra-caladea fonts-dejavu-core \
libcairo2 libcups2t64 libdbus-1-3 libglib2.0-0t64 libice6 libnss3 libsm6 libx11-xcb1 libxinerama1 libxrandr2 \
&& curl -fsSL "https://downloadarchive.documentfoundation.org/libreoffice/old/${LIBREOFFICE_VERSION}/deb/x86_64/LibreOffice_${LIBREOFFICE_VERSION}_Linux_x86-64_deb.tar.gz" \
| tar -xz -C /tmp \
&& dpkg -i /tmp/LibreOffice_*/DEBS/*.deb \
&& ln -s /opt/libreoffice*/program/soffice /usr/local/bin/soffice \
&& rm -rf /tmp/LibreOffice_* /var/lib/apt/lists/*
# LibreOffice has no font for Calibri Light, the heading font of Office's theme and of docx's default styles, and would
# draw it in Noto Serif, whose lines are taller
COPY fonts.conf /etc/fonts/local.conf
# LibreOffice keeps its settings in the home directory
ENV HOME=/tmp
WORKDIR /work