fix: declare global declareFont

This commit is contained in:
Marc Emmanuel 2026-02-16 21:54:11 +01:00
parent e49be0b48f
commit f7d52997c4

View file

@ -1,6 +1,7 @@
import { byId } from "../utils";
declare global {
var declareFont: (font: FontDefinition) => void;
var getUsedFonts: (svg: SVGSVGElement) => FontDefinition[];
var loadFontsAsDataURI: (
fonts: FontDefinition[],
@ -269,16 +270,16 @@ window.fonts = [
},
];
declareDefaultFonts(); // execute once on load
function declareFont(font: FontDefinition) {
window.declareFont = (font: FontDefinition) => {
const { family, src, ...rest } = font;
addFontOption(family);
if (!src) return;
const fontFace = new FontFace(family, src, { ...rest, display: "block" });
document.fonts.add(fontFace);
}
};
declareDefaultFonts(); // execute once on load
function declareDefaultFonts() {
fonts.forEach((font) => {