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