diff --git a/packages/lint/src/rules/fonts.test.ts b/packages/lint/src/rules/fonts.test.ts index 8a22f53f3..fc5c3ddb2 100644 --- a/packages/lint/src/rules/fonts.test.ts +++ b/packages/lint/src/rules/fonts.test.ts @@ -146,6 +146,30 @@ describe("font rules", () => { expect(findings).toHaveLength(0); }); + it("does not flag a system font declared via @font-face src: local()", async () => { + // Regression: two independent reports of this rule hard-erroring on OS + // system fonts (Hiragino Sans, Microsoft YaHei) that have no downloadable + // file. src: local(...) already satisfies the check (extractFontFaceFamilies + // only looks at the font-family declaration, not the src value) — the gap + // was that the fixHint didn't mention this as an option. + const html = `
+ +
`; + const findings = await findByCode(html, "font_family_without_font_face"); + expect(findings).toHaveLength(0); + }); + + it("fixHint mentions the local() pattern for system fonts", async () => { + const html = `
+ +
`; + const findings = await findByCode(html, "font_family_without_font_face"); + expect(findings[0]!.fixHint).toContain("local("); + }); + it("does not flag generic font families", async () => { const html = `
diff --git a/packages/lint/src/rules/fonts.ts b/packages/lint/src/rules/fonts.ts index 611fb4a18..f7c7a8818 100644 --- a/packages/lint/src/rules/fonts.ts +++ b/packages/lint/src/rules/fonts.ts @@ -232,7 +232,10 @@ export const fontRules: Array<(ctx: LintContext) => HyperframeLintFinding[]> = [ "Text will fall back to a generic font, producing incorrect typography in the video.", fixHint: "Add @font-face { font-family: '...'; src: url('capture/assets/fonts/...woff2'); } " + - "for each font family, pointing to the captured .woff2 files.", + "for each font family, pointing to the captured .woff2 files. For an OS-bundled " + + "system font (e.g. Hiragino Sans, Microsoft YaHei) that has no downloadable file, " + + "use src: local('Exact Font Name') instead — the declaration alone satisfies this " + + "check without needing a font file.", }); return findings; },