diff --git a/assets/fonts/Noto-Emoji.ttf b/assets/fonts/Noto-Emoji.ttf deleted file mode 100644 index 8fdd4d79..00000000 Binary files a/assets/fonts/Noto-Emoji.ttf and /dev/null differ diff --git a/assets/fonts/Symbola.otf b/assets/fonts/Symbola.otf new file mode 100644 index 00000000..bbd5f852 Binary files /dev/null and b/assets/fonts/Symbola.otf differ diff --git a/package.json b/package.json index 61a89482..0682a24f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "129.9.0", + "version": "129.9.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/structures/Font.js b/structures/Font.js index 1e311a72..09a250a1 100644 --- a/structures/Font.js +++ b/structures/Font.js @@ -11,10 +11,7 @@ const weights = { 900: 'heavy', 950: 'extraBlack' }; -const variants = { - 'Noto-CJK.otf': 'Noto Sans', - 'Noto-Emoji.ttf': 'Noto Sans' -}; +const fallbacks = ['Symbola', 'Noto-CJK']; module.exports = class Font { constructor(path, filename, metadata) { @@ -25,6 +22,7 @@ module.exports = class Font { this.weight = weights[metadata.weight] || metadata.weight || 'normal'; this.type = metadata.type; this.registered = false; + this.fallbacks = fallbacks.filter(fallback => fallback !== this.filenameNoExt); } register() { @@ -33,8 +31,9 @@ module.exports = class Font { return registerFont(this.path, { family: this.filenameNoExt, style: this.style, weight: this.weight }); } - toCanvasString(size) { - return `${this.style} ${this.weight} ${size}px ${this.filenameNoExt}`; + toCanvasString(size, fallbacks = true) { + const shouldFall = fallbacks ? `, ${this.fallbacks.join(', ')}` : ''; + return `${this.style} ${this.weight} ${size}px ${this.filenameNoExt}${shouldFall}`; } get filenameNoExt() { @@ -44,4 +43,8 @@ module.exports = class Font { get isVariant() { return variants[this.filename]; } + + get isFallback() { + return fallbacks.includes(this.filenameNoExt); + } }; diff --git a/types/font.js b/types/font.js index 6fb153de..5cfbac6e 100644 --- a/types/font.js +++ b/types/font.js @@ -9,6 +9,7 @@ module.exports = class FontArgumentType extends ArgumentType { validate(value) { const choice = value.toLowerCase(); let found = this.client.fonts.filter(font => { + if (font.isFallback) return false; if (font.isVariant) return false; if (font.name.toLowerCase().includes(choice)) return true; if (font.filenameNoExt.toLowerCase().includes(choice)) return true; @@ -24,13 +25,14 @@ module.exports = class FontArgumentType extends ArgumentType { if (foundExact.size === 1) return true; if (foundExact.size > 0) found = foundExact; return found.size <= 15 - ? `${disambiguation(found.map(font => escapeMarkdown(font.name)), 'fonts', null)}\n` + ? `${disambiguation(found.map(font => escapeMarkdown(font.filenameNoExt)), 'fonts', null)}\n` : 'Multiple fonts found. Please be more specific.'; } parse(value) { const choice = value.toLowerCase(); const found = this.client.fonts.filter(font => { + if (font.isFallback) return false; if (font.isVariant) return false; if (font.name.toLowerCase().includes(choice)) return true; if (font.filenameNoExt.toLowerCase().includes(choice)) return true;