(ar)(ko) fix banner font registration for banner

This commit is contained in:
Valentyne Stigloher 2024-05-24 23:24:43 +02:00
parent 153867d79d
commit 456ca7e126
3 changed files with 9 additions and 7 deletions

View File

@ -3,24 +3,26 @@ import fs from 'fs';
const __dirname = new URL('.', import.meta.url).pathname;
const vars = {};
const vars: Record<string, string> = {};
for (const [, name, value] of fs.readFileSync(`${__dirname}/../data/variables.scss`).toString('utf-8')
.matchAll(/^\$([^:]+): '([^']+)'(?:, '[^']+')*;$/gm)) {
vars[name] = value;
}
const fontSources = {
Quicksand: 'quicksand-v21-latin-ext_latin-{weight}.ttf',
const fontSources: Record<string, string> = {
'Baloo Bhaijaan 2': 'baloo-bhaijaan-2-v19-arabic_latin-{weight}.ttf',
'Nanum Gothic': 'nanum-gothic-v17-latin_korean-{weight}.ttf',
Nunito: 'nunito-v16-latin-ext_latin_cyrillic-ext_cyrillic-{weight}.ttf',
Quicksand: 'quicksand-v21-latin-ext_latin-{weight}.ttf',
'Zen Maru Gothic': 'zen-maru-gothic-v4-latin_japanese-{weight}.ttf',
};
const weightsValues = {
const weightsValues: Record<string, string> = {
bold: '700',
};
export const registerLocaleFont = (v, weights = ['regular']) => {
export const registerLocaleFont = (v: string, weights: string[] = ['regular']): string => {
const family = vars[v];
const source = fontSources[family];
for (const weight of weights) {

View File

@ -8,7 +8,7 @@ import { loadTsv } from '../../src/tsv.js';
import { handleErrorAsync } from '../../src/helpers.ts';
import { Translator } from '../../src/translator.js';
import { CacheObject } from '../../src/cache.js';
import { registerLocaleFont } from '../localeFont.js';
import { registerLocaleFont } from '../localeFont.ts';
const translations = loadSuml('translations');
const baseTranslations = loadSumlFromBase('locale/_base/translations');

View File

@ -5,7 +5,7 @@ import { createCanvas, loadImage, registerFont } from 'canvas';
import { loadSuml } from '../loader.ts';
import { clearKey, handleErrorAsync, isTroll } from '../../src/helpers.ts';
import { caches } from '../../src/cache.js';
import { registerLocaleFont } from '../localeFont.js';
import { registerLocaleFont } from '../localeFont.ts';
import auditLog from '../audit.ts';
const translations = loadSuml('translations');