new fonts

This commit is contained in:
Azgaar 2022-05-10 22:45:07 +03:00
parent 566a811d1f
commit 4251d0c0ea
4 changed files with 95 additions and 13 deletions

View file

@ -546,15 +546,15 @@ styleFontAdd.addEventListener("click", function () {
buttons: {
Add: function () {
const family = addFontNameInput.value;
const src = addFontURLInput.value;
const method = addFontMethod.value;
if (!family) return tip("Please provide a font name", false, "error");
const existingFont = fonts.find(font => font.family === family);
const existingFont = method === "fontURL" ? fonts.find(font => font.family === family && font.src === src) : fonts.find(font => font.family === family);
if (existingFont) return tip("The font is already added", false, "error");
const method = addFontMethod.value;
const url = addFontURLInput.value;
if (method === "fontURL") addWebFont(family, url);
if (method === "fontURL") addWebFont(family, src);
else if (method === "googleFont") addGoogleFont(family);
else if (method === "localFont") addLocalFont(family);