From cd1a5f240fb0c503fccd92e9bda3f3a23e10d4ed Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 11 Sep 2024 14:19:10 -0700 Subject: ... --- app.mjs | 31 +++++++++++++------------------ font.ttf | Bin 0 -> 55400 bytes ocr-a-ext.ttf | Bin 55400 -> 0 bytes package-lock.json | 1 + 4 files changed, 14 insertions(+), 18 deletions(-) create mode 100644 font.ttf delete mode 100644 ocr-a-ext.ttf diff --git a/app.mjs b/app.mjs index a558885..7325da9 100755 --- a/app.mjs +++ b/app.mjs @@ -4,14 +4,14 @@ import { registerFont } from "canvas"; const defaultFont = "OCR A Extended"; if (process.platform == "linux") { - console.warn( - "node-canvas does not support directly using font file in Linux (see https://github.com/Automattic/node-canvas/issues/2097#issuecomment-1803950952), please copy ./ocr-a-ext.ttf in this folder to your local font folder (~/.fonts/) or install it system-wide.", - ); -} else { - registerFont(`${import.meta.dirname}/ocr-a-ext.ttf`, { - family: defaultFont, - }); + process.env.FONTCONFIG_FILE = import.meta.dirname; + //console.warn( + // "node-canvas does not support directly using font file in Linux (see https://github.com/Automattic/node-canvas/issues/2097#issuecomment-1803950952), please copy ./ocr-a-ext.ttf in this folder to your local font folder (~/.fonts/) or install it system-wide.", + //); } +registerFont(`${import.meta.dirname}/font.ttf`, { + family: defaultFont, +}); import { discover, HAPTIC } from "loupedeck"; import { readFile } from "fs/promises"; @@ -241,18 +241,13 @@ const drawKey = async (id, conf, pressed) => { c.lineWidth = 2; c.strokeStyle = fg; c.strokeRect(padding, padding, w - padding * 2, h - padding * 2); - if (conf != null) { - renderMultiLineText( - c, - 0, - 0, - w, - h, - getLabels(conf), - getTextStyles(conf), - conf, - ); + const labels = getLabels(conf); + const styles = getTextStyles(conf); + for (let i = 0; i < labels.length; i++) { + styles.color_fg[i] = fg; + } + renderMultiLineText(c, 0, 0, w, h, labels, styles, conf); } // otherwise the empty key style is still drawn }); diff --git a/font.ttf b/font.ttf new file mode 100644 index 0000000..0e77e20 Binary files /dev/null and b/font.ttf differ diff --git a/ocr-a-ext.ttf b/ocr-a-ext.ttf deleted file mode 100644 index 0e77e20..0000000 Binary files a/ocr-a-ext.ttf and /dev/null differ diff --git a/package-lock.json b/package-lock.json index 6ea17ef..518dbb4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -582,6 +582,7 @@ "resolved": "https://registry.npmjs.org/canvas/-/canvas-2.11.2.tgz", "integrity": "sha512-ItanGBMrmRV7Py2Z+Xhs7cT+FNt5K0vPL4p9EZ/UX/Mu7hFbkxSjKF2KVtPwX7UYWp7dRKnrTvReflgrItJbdw==", "hasInstallScript": true, + "license": "MIT", "dependencies": { "@mapbox/node-pre-gyp": "^1.0.0", "nan": "^2.17.0", -- cgit v1.2.3-70-g09d2