Open History to see the last commit
1import { BUNDLED_FONTS } from "@betteroffice/fonts";
2import { describe, expect, it } from "vite-plus/test";
3import { sheetFace, wordFonts } from "./fonts";
4
5const notoSansJp = BUNDLED_FONTS.find((face) => face.file === "NotoSansJP-Regular.otf")!;
6const fonts = wordFonts();
7
8describe("wordFonts", () => {
9 it.each([
10 ["Yu Gothic", fonts.resolve("Yu Gothic", false, false)],
11 ["MS Gothic", fonts.resolve("MS Gothic", false, false)],
12 ["the Japanese fallback", fonts.resolveScriptFallback?.("cjk-jp", false, false)],
13 ])("draws %s with Noto Sans JP", async (_, load) => {
14 const bytes = await load?.();
15
16 expect(bytes?.byteLength).toBe(notoSansJp.byteLength);
17 });
18});
19
20it.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);