From 38e852190df6f19c8a664292239fa56f9bcdc2ef Mon Sep 17 00:00:00 2001 From: Steffen Becker Date: Fri, 7 Aug 2026 17:32:24 +0000 Subject: [PATCH] fix: keep a header/footer's own font on DOCX import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit blockDefaults(baseRun) made the Header/Footer style's own font the yardstick, so a run matching it imported without marks. The zone carries no styleName and no style CSS reaches it, so it then rendered in the editor default instead — an Arial footer came back as Liberation Serif, 2.3mm narrow per line. --- src/lib/import/docx.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/import/docx.ts b/src/lib/import/docx.ts index d2af5ad..b226596 100644 --- a/src/lib/import/docx.ts +++ b/src/lib/import/docx.ts @@ -1552,7 +1552,10 @@ function convertHfPart(relId: string | null, ctx: Ctx): HfDoc { } boxMaps.push(readParaBox(ppr)); const baseRun = hfCtx.styles.paragraphRun(fc(ppr, 'pStyle') ? wVal(fc(ppr, 'pStyle')!) : null); - inline.push(...convertInline(p, hfCtx, baseRun, blockDefaults(baseRun, null, false), true).filter((n) => n.type !== PB_MARKER)); + // The zone carries no styleName and no style CSS reaches it, so the yardstick is the + // editor's own defaults — what the Header/Footer style provides has to become marks + // (mirrors odt.ts convertHfZone, which passes no style name either). + inline.push(...convertInline(p, hfCtx, baseRun, blockDefaults({}, null, false), true).filter((n) => n.type !== PB_MARKER)); } // An all-empty zone is dropped unless it carries a background/rule line (a footer that // is just a colored line has no text). The zone collapses to one paragraph (mergeHfBox).