widalarmeta: Only load required font

master
Erik Andresen 2023-05-05 04:57:49 +02:00
parent 957ccc431a
commit e8a5d68d7d
1 changed files with 10 additions and 7 deletions

View File

@ -1,7 +1,4 @@
(() => { (() => {
require("Font5x9Numeric7Seg").add(Graphics);
require("FontTeletext5x9Ascii").add(Graphics);
let config; let config;
function loadSettings() { function loadSettings() {
@ -12,6 +9,12 @@
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2 font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
}, require("Storage").readJSON("widalarmeta.json",1) || {}); }, require("Storage").readJSON("widalarmeta.json",1) || {});
if (config.font == 0) {
require("Font5x9Numeric7Seg").add(Graphics);
} else if (config.font == 1) {
require("FontTeletext5x9Ascii").add(Graphics);
}
} }
loadSettings(); loadSettings();
@ -68,13 +71,13 @@
if (drawSeconds) { if (drawSeconds) {
text += ":" + seconds.padStart(2, '0'); text += ":" + seconds.padStart(2, '0');
} }
if (config.font == 1) { if (config.font == 0) {
g.setFont("5x9Numeric7Seg:1x2");
} else if (config.font == 1) {
g.setFont("Teletext5x9Ascii:1x2"); g.setFont("Teletext5x9Ascii:1x2");
} else if (config.font == 2) {
g.setFont("6x8:1x2");
} else { } else {
// Default to this if no other font is set. // Default to this if no other font is set.
g.setFont("5x9Numeric7Seg:1x2"); g.setFont("6x8:1x2");
} }
g.drawString(text, this.x+1, this.y+12); g.drawString(text, this.x+1, this.y+12);