Skip to content

Commit 0f8912d

Browse files
committed
added newline support to drawText
fixed font
1 parent f951ead commit 0f8912d

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

fonts/neomatrix/neomatrix.ttf

-8 Bytes
Binary file not shown.

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,7 @@ window.onload = function () {
370370
}
371371
case "4": {
372372
let center = [Math.floor((columns - 7 * options.ui_clock_scale) / 2), Math.floor((rows + options.ui_clock_scale) / 2)];
373-
drawTextOnMask(hour, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY - 1 * options.ui_clock_scale, options.ui_clock_scale);
374-
drawTextOnMask(minute, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY + 5 * options.ui_clock_scale, options.ui_clock_scale);
373+
drawTextOnMask(hour + "\n" + minute, center[0] + options.ui_clock_positionX, center[1] + options.ui_clock_positionY - 1 * options.ui_clock_scale, options.ui_clock_scale);
375374
break;
376375
}
377376
}
@@ -380,7 +379,10 @@ window.onload = function () {
380379
function drawTextOnMask(text, x, y, scale) {
381380
mask.font = options.ui_font_size * 5 * scale + "px neo-matrix";
382381
mask.fillStyle = "#FFF";
383-
mask.fillText(text, options.ui_font_size * x - font_fraction, options.ui_font_size * y + font_fraction);
382+
lines = text.split("\n");
383+
for (let i = 0; i < lines.length; i++) {
384+
mask.fillText(lines[i], options.ui_font_size * x - font_fraction, options.ui_font_size * y + font_fraction + (6 * i * options.ui_font_size * options.ui_clock_scale));
385+
}
384386
}
385387

386388
function drawMask() {

0 commit comments

Comments
 (0)