Skip to content
Open
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
2 changes: 2 additions & 0 deletions docs/reference/lint-rules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,8 @@ Source: `packages/lint/src/rules/fonts.ts`.

**Fix:** Declare each family with `@font-face` pointing at the captured `.woff2` files, or bundle the font under `capture/assets/fonts/`.

The declaration may use a quoted or unquoted family name. If `font-family` is the last descriptor in the block, its final semicolon is optional.

### `system_font_will_alias`

**Warning.** A system font family is used without a matching `@font-face`; in distributed rendering system-font capture is disabled, so the font is substituted at render time and text can reflow. Only reported when the linter runs with the `distributed: true` option (linting for distributed or Lambda renders); a local render captures the system font as designed, so it is not flagged there.
Expand Down
14 changes: 14 additions & 0 deletions packages/lint/src/rules/fonts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ describe("font rules", () => {
expect(findings).toHaveLength(0);
});

it.each(["ProjectFont", "Project Font"])(
"recognizes an unquoted final font-family descriptor without a semicolon: %s",
async (family) => {
const html = `<div data-composition-id="test" data-width="1920" data-height="1080">
<style>
@font-face { src: local('DejaVu Sans'); font-family: ${family} }
body { font-family: ${family}, sans-serif }
</style>
</div>`;
const findings = await findByCode(html, "font_family_without_font_face");
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
Expand Down
2 changes: 1 addition & 1 deletion packages/lint/src/rules/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function stripCssComments(css: string): string {
function extractFontFaceFamilies(styles: Array<{ content: string }>): Set<string> {
const families = new Set<string>();
const fontFaceRe = /@font-face\s*\{[^}]*\}/gi;
const familyRe = /font-family\s*:\s*(['"]?)([^;'"]+)\1/i;
const familyRe = /font-family\s*:\s*(['"]?)([^;}'"]+)\1/i;
for (const style of styles) {
const content = stripCssComments(style.content);
let match: RegExpExecArray | null;
Expand Down
Loading