mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-04-05 06:57:24 +02:00
fix: declare global declareFont
This commit is contained in:
parent
e49be0b48f
commit
f7d52997c4
1 changed files with 5 additions and 4 deletions
|
|
@ -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) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue