Skip to content

Write HTML. Render video. Built for agents.

fix(lint): mention src: local() for system fonts in font_family_without_font_face (#1859)

Miguel Ángelb7eb0dfb5a87
diff --git a/packages/lint/src/rules/fonts.test.ts b/packages/lint/src/rules/fonts.test.ts
index 8a22f53f39..fc5c3ddb2b 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 = `<div data-composition-id="test" data-width="1920" data-height="1080">
+ <style>
+ @font-face { font-family: 'Microsoft YaHei'; src: local('Microsoft YaHei'); }
+ body { font-family: 'Microsoft YaHei', sans-serif; }
+ </style>
+ </div>`;
+ 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 = `<div data-composition-id="test" data-width="1920" data-height="1080">
+ <style>body { font-family: 'GT Walsheim', sans-serif; }</style>
+ </div>`;
+ 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 = `<div data-composition-id="test" data-width="1920" data-height="1080">
<style>body { font-family: monospace; }</style>
diff --git a/packages/lint/src/rules/fonts.ts b/packages/lint/src/rules/fonts.ts
index 611fb4a18b..f7c7a8818f 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;
},