Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ describe('convertOmmlToMathml', () => {
expect(mi!.textContent).toBe('x');
});

it('emits font-family via --sd-math-font-family with Cambria Math fallback (SD-2634)', () => {
// Consumers override the math font via the --sd-math-font-family CSS
// variable. When the variable is unset, the var() fallback resolves to
// Cambria Math so embedders of the painter without the superdoc
// stylesheet still render correctly.
const omml = {
name: 'm:oMath',
elements: [{ name: 'm:r', elements: [{ name: 'm:t', elements: [{ type: 'text', text: 'x' }] }] }],
};
const result = convertOmmlToMathml(omml, doc);
expect(result!.getAttribute('style')).toBe('font-family: var(--sd-math-font-family, "Cambria Math", math)');
});

it('classifies numbers as <mn>', () => {
const omml = {
name: 'm:oMath',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ export function convertOmmlToMathml(ommlJson: unknown, doc: Document): Element |

const root = ommlJson as OmmlJsonNode;
const mathEl = doc.createElementNS(MATHML_NS, 'math');
mathEl.setAttribute('style', 'font-family: "Cambria Math", math');
// Fallback chain covers consumers that embed painter-dom without the
// superdoc stylesheet — the `var()` still resolves to Cambria Math then
// the generic `math` family.
mathEl.setAttribute('style', 'font-family: var(--sd-math-font-family, "Cambria Math", math)');

if (root.name === 'm:oMathPara') {
mathEl.setAttribute('display', 'block');
Expand Down
3 changes: 3 additions & 0 deletions packages/superdoc/src/assets/styles/helpers/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,7 @@
--sd-proofing-style-color: #805ad5;
--sd-proofing-underline-thickness: 1.5px;
--sd-proofing-underline-offset: 2px;

/* Math: rendered equation font */
--sd-math-font-family: 'Cambria Math', math;
}
Loading