filterAndTransformFontFaces() — astro Function Reference
Architecture documentation for the filterAndTransformFontFaces() function in filter-and-transform-font-faces.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD dc47ec07_dd0b_8c1a_39f6_c30fa5d563f2["filterAndTransformFontFaces()"] 58296d83_574c_3fee_6296_26c77d438c1b["filter-and-transform-font-faces.ts"] dc47ec07_dd0b_8c1a_39f6_c30fa5d563f2 -->|defined in| 58296d83_574c_3fee_6296_26c77d438c1b style dc47ec07_dd0b_8c1a_39f6_c30fa5d563f2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/assets/fonts/core/filter-and-transform-font-faces.ts lines 6–55
export function filterAndTransformFontFaces({
fonts,
fontTypeExtractor,
fontFileIdGenerator,
urlResolver,
family,
}: {
fonts: Array<unifont.FontFaceData>;
fontTypeExtractor: FontTypeExtractor;
fontFileIdGenerator: FontFileIdGenerator;
urlResolver: UrlResolver;
family: Pick<ResolvedFontFamily, 'cssVariable'>;
}) {
return (
fonts
// Avoid getting too much font files
.filter((font) => (typeof font.meta?.priority === 'number' ? font.meta.priority <= 1 : true))
// Collect URLs
.map((font) => ({
...font,
src: font.src.map((source) => {
if ('name' in source) {
return source;
}
// We handle protocol relative URLs here, otherwise they're considered absolute by the font
// fetcher which will try to read them from the file system
const originalUrl = source.url.startsWith('//') ? `https:${source.url}` : source.url;
let format = FONT_FORMATS.find((e) => e.format === source.format);
if (!format) {
format = FONT_FORMATS.find((e) => e.type === fontTypeExtractor.extract(source.url))!;
}
const id = fontFileIdGenerator.generate({
cssVariable: family.cssVariable,
font,
originalUrl,
type: format.type,
});
const url = urlResolver.resolve(id);
const newSource: unifont.RemoteFontSource = {
originalURL: originalUrl,
url,
format: format.format,
tech: source.tech,
};
return newSource;
}),
}))
);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does filterAndTransformFontFaces() do?
filterAndTransformFontFaces() is a function in the astro codebase, defined in packages/astro/src/assets/fonts/core/filter-and-transform-font-faces.ts.
Where is filterAndTransformFontFaces() defined?
filterAndTransformFontFaces() is defined in packages/astro/src/assets/fonts/core/filter-and-transform-font-faces.ts at line 6.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free