add fallback font to the uploaded one

This commit is contained in:
Oleg Isonen committed 2022-09-25 12:09:22 +03:00
1 parent 51b00cddc7
commit 96c5f7ecfd
3 files changed
+16 -13

No files matched your search

@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`getFontFaces() same family, but different formats 1`] = `
Array [
Object {
"fontDisplay": "swap",
"fontFamily": "Roboto, sans-serif",
"fontStyle": "normal",
"fontWeight": 400,
"src": "url('/fonts/roboto.woff') format('woff'), url('/fonts/roboto.ttf') format('truetype')",
},
]
`;
+1 -11
View File
@@ -22,16 +22,6 @@ describe("getFontFaces()", () => {
path: "/fonts/roboto.ttf",
},
];
expect(getFontFaces(assets)).toMatchInlineSnapshot(`
[
{
"fontDisplay": "swap",
"fontFamily": "Roboto",
"fontStyle": "normal",
"fontWeight": 400,
"src": "url('/fonts/roboto.woff') format('woff'), url('/fonts/roboto.ttf') format('truetype')",
},
]
`);
expect(getFontFaces(assets)).toMatchSnapshot();
});
});
+2 -2
View File
@@ -1,4 +1,4 @@
import { FONT_FORMATS } from "./constants";
import { FONT_FORMATS, DEFAULT_FONT_FALLBACK } from "./constants";
import type { FontMeta } from "./schema";
import type { FontFormat } from "./types";
@@ -16,7 +16,7 @@ export const getFontFaces = (assets: Array<PartialFontAsset>) => {
if (face === undefined) {
faces.set(asset.meta.family, {
fontFamily: asset.meta.family,
fontFamily: `${asset.meta.family}, ${DEFAULT_FONT_FALLBACK}`,
fontStyle: asset.meta.style,
fontWeight: asset.meta.weight,
fontDisplay: "swap" as const,