fix(converter): preserve theme rFonts on DOCX round-trip (SD-2894)#3225
Open
tupizz wants to merge 1 commit into
Open
fix(converter): preserve theme rFonts on DOCX round-trip (SD-2894)#3225tupizz wants to merge 1 commit into
tupizz wants to merge 1 commit into
Conversation
The cascade's font-slot dedup only handled the ascii/asciiTheme pair, so a higher-priority style with hAnsiTheme/eastAsiaTheme/cstheme would still leave the lower-priority concrete name in place. Word reads the concrete value as an override that defeats per-script theme resolution — Latin body text mapped to majorBidi rendered as Calibri Light instead of the per-script font (Times New Roman for Hebrew/Arab). Extend the dedup to all four <w:rFonts> slots, and add the same logic to calculateInlineRunPropertiesPlugin so theme refs from the imported run survive the mark-driven recompute that runs on initial load. Verified with a round-trip integration test on the customer fixture: asciiTheme count 65 → 65 (was dropping to ~25 before the fix), no concrete font substitutions on runs that originally carried theme references.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
combineRunPropertiesfont-slot dedup to cover all four<w:rFonts>script slots (was onlyascii/asciiTheme), so a higher-priority style withhAnsiTheme/eastAsiaTheme/csthemeno longer leaves the lower-priority concrete name in place.calculateInlineRunPropertiesPluginso theme references survive the mark-driven recompute that runs after import.Why
Customer fixture in SD-2894 had every body run mapped to
<w:rFonts w:asciiTheme="majorBidi" w:hAnsiTheme="majorBidi" w:cstheme="majorBidi"/>. The cascade only knew how to droptarget.asciiwhensource.asciiThemewas present — the other three slots fell through, so the merged run carried{ ascii: "Arial", hAnsi: "Arial", cs: "Arial", asciiTheme: "majorBidi", hAnsiTheme: "majorBidi", cstheme: "majorBidi" }. Word treats the concrete value as an override that defeats per-script theme resolution: Latin body text mapped tomajorBidirendered as Calibri Light instead of the per-script font (Times New Roman for Hebrew/Arab).A second loss happened in
calculateInlineRunPropertiesPluginon initial load — the plugin computes fontFamily from textStyle marks (which only carry concrete CSS names) and overroderunProperties.fontFamilywith concrete-only values, dropping the theme references that the import had stored.Test plan
sd-2894-theme-rfonts-roundtrip.test.js) that round-trips the customer fixture and assertsw:asciiTheme/w:hAnsiTheme/w:csthemecounts don't drop and that no source theme reference becomes a concrete font on export.ooxml-rFonts-rstyle-linked-combos-roundtriptest still passes.pnpm testforsuper-editor(12 708 / 12 721 pass).@superdoc/style-enginecascade unit tests pass.asciiThemecount: 65 → 65 (was 65 → ~25). No Calibri Light substitutions on body text. Per-script resolution intact.Verified diffs on the customer fixture
w:asciiThemeindocument.xmlw:hAnsiThemeindocument.xmlw:csthemeindocument.xmlw:ascii="Calibri Light"runs indocument.xml