Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local font source is not recognized as valid #113

Open
Rarst opened this issue Jul 28, 2022 · 0 comments
Open

Local font source is not recognized as valid #113

Rarst opened this issue Jul 28, 2022 · 0 comments

Comments

@Rarst
Copy link

Rarst commented Jul 28, 2022

Only font faces having src: url() are treated as valid, so src: local() ones would always be considered invalid and dropped, even if they are detected as critical fonts.

@font-face {
  font-family: "Alegreya-fallback";
  size-adjust: 101%;
  src: local("Times New Roman");
}

src = (decl.value.match(/url\s*\(\s*(['"]?)(.+?)\1\s*\)/) || [])[2];
} else if (decl.prop === 'font-family') {
family = decl.value;
}
}
if (src && shouldPreloadFonts && preloadedFonts.indexOf(src) === -1) {
preloadedFonts.push(src);
const preload = document.createElement('link');
preload.setAttribute('rel', 'preload');
preload.setAttribute('as', 'font');
preload.setAttribute('crossorigin', 'anonymous');
preload.setAttribute('href', src.trim());
document.head.appendChild(preload);
}
// if we're missing info, if the font is unused, or if critical font inlining is disabled, remove the rule:
if (
!family ||
!src ||

Related #112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant