Skip to content

Commit 191e230

Browse files
committed
fix(web): retain bundled fonts for missing spreadsheet styles
1 parent 004b286 commit 191e230

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎apps/web/src/components/files/office/fonts.browser.test.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BUNDLED_FONTS } from "@betteroffice/fonts";
22
import { describe, expect, it } from "vite-plus/test";
3-
import { wordFonts } from "./fonts";
3+
import { sheetFace, wordFonts } from "./fonts";
44

55
const notoSansJp = BUNDLED_FONTS.find((face) => face.file === "NotoSansJP-Regular.otf")!;
66
const fonts = wordFonts();
@@ -16,3 +16,14 @@ describe("wordFonts", () => {
1616
expect(bytes?.byteLength).toBe(notoSansJp.byteLength);
1717
});
1818
});
19+
20+
it.each([false, true])(
21+
"uses the available Comic Relief face for italic spreadsheet text (bold: %s)",
22+
(bold) => {
23+
expect(sheetFace("Comic Relief", bold, true)).toMatchObject({
24+
family: "Comic Relief",
25+
weight: bold ? 700 : 400,
26+
style: "normal",
27+
});
28+
},
29+
);

‎apps/web/src/components/files/office/fonts.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export function presentationFace(family: string, bold: boolean, italic: boolean)
3838
/** The face Excel's cells draw a family with when it is missing: its metric-compatible or bundled face, if any. */
3939
export function sheetFace(family: string, bold: boolean, italic: boolean) {
4040
return (
41-
resolveMetricCompatFace(family, bold, italic) ?? resolveBundledFamilyFace(family, bold, italic)
41+
resolveMetricCompatFace(family, bold, italic) ??
42+
resolveBundledFamilyFace(family, bold, italic) ??
43+
resolveBundledFamilyFace(family, bold, false) ??
44+
resolveBundledFamilyFace(family, false, false)
4245
);
4346
}
4447

0 commit comments

Comments
 (0)