From 06bee1d3f1ed5c3d0354cfc98f7d61cbdc8172d7 Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Mon, 10 Aug 2026 19:58:17 +0000 Subject: [PATCH] fix: the same run-size yardstick on the DOCX side Mirrors the ODF fix: a block that cannot name its style is measured against the default paragraph style but renders at its own, so a run matching the default was suppressed and came out at the wrong size. --- src/lib/import/docx.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/import/docx.ts b/src/lib/import/docx.ts index 7a1b5ac..ac552b2 100644 --- a/src/lib/import/docx.ts +++ b/src/lib/import/docx.ts @@ -791,7 +791,13 @@ function convertParagraph(el: Element, ctx: Ctx, kind: BlockKind, boldByDefault: // carry the formatting instead, so it is measured against the default style: the only // thing re-applied on import. A caption's italic and colour live nowhere else. const defaults = blockDefaults(name ? baseRun : ctx.styles.paragraphRun(ctx.styles.defaultParagraphStyle()), level, boldByDefault); - const content = convertInline(el, ctx, baseRun, defaults, false); + // A run inherits the block's own size, not the default style's, so that is what it is + // measured against — else a size the block overrides is suppressed and lost (odt.ts). + const ownSizePt = blockDefaults(baseRun, level, boldByDefault).fontSizePt; + const runDefaults = Math.abs(ownSizePt - defaults.fontSizePt) > 0.05 + ? { ...defaults, fontSizePt: ownSizePt } + : defaults; + const content = convertInline(el, ctx, baseRun, runDefaults, false); if (name) { ctx.usedStyles.add(styleId!);