Skip to content

Commit bd74708

Browse files
committed
add pixel font plugin
1 parent ef4dd7e commit bd74708

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"author": "Luiz Bills",
1818
"license": "MIT",
1919
"devDependencies": {
20-
"esbuild": "^0.25.5"
20+
"esbuild": "^0.25.6"
2121
},
2222
"dependencies": {
2323
"@babel/standalone": "^7.28.0",
@@ -26,6 +26,7 @@
2626
"@litecanvas/plugin-asset-loader": "latest",
2727
"@litecanvas/plugin-frame-rate-meter": "latest",
2828
"@litecanvas/plugin-migrate": "latest",
29+
"@litecanvas/plugin-pixel-font": "^0.0.1",
2930
"@litecanvas/utils": "latest",
3031
"codemirror": "^6.0.2",
3132
"eslint-linter-browserify": "9.30.0",

public/litecanvas.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,25 @@
22062206
}
22072207
window.pluginFrameRateMeter = A;
22082208
})();
2209+
(() => {
2210+
var u = [[24, 60, 60, 24, 24, , 24], [54, 54, , , , , ,], [54, 54, 127, 54, 127, 54, 54], [12, 62, 3, 30, 48, 31, 12], [, 99, 51, 24, 12, 102, 99], [28, 54, 28, 110, 59, 51, 110], [6, 6, 3, , , , ,], [24, 12, 6, 6, 6, 12, 24], [6, 12, 24, 24, 24, 12, 6], [, 102, 60, 255, 60, 102, ,], [, 12, 12, 63, 12, 12, ,], [, , , , , 12, 12, 6], [, , , 63, , , ,], [, , , , , 12, 12], [96, 48, 24, 12, 6, 3, 1], [62, 99, 115, 123, 111, 103, 62], [12, 14, 12, 12, 12, 12, 63], [30, 51, 48, 28, 6, 51, 63], [30, 51, 48, 28, 48, 51, 30], [56, 60, 54, 51, 127, 48, 120], [63, 3, 31, 48, 48, 51, 30], [28, 6, 3, 31, 51, 51, 30], [63, 51, 48, 24, 12, 12, 12], [30, 51, 51, 30, 51, 51, 30], [30, 51, 51, 62, 48, 24, 14], [, 12, 12, , , 12, 12], [, 12, 12, , , 12, 12, 6], [24, 12, 6, 3, 6, 12, 24], [, , 63, , , 63, ,], [6, 12, 24, 48, 24, 12, 6], [30, 51, 48, 24, 12, , 12], [62, 99, 123, 123, 123, 3, 30], [12, 30, 51, 51, 63, 51, 51], [63, 102, 102, 62, 102, 102, 63], [60, 102, 3, 3, 3, 102, 60], [31, 54, 102, 102, 102, 54, 31], [127, 70, 22, 30, 22, 70, 127], [127, 70, 22, 30, 22, 6, 15], [60, 102, 3, 3, 115, 102, 124], [51, 51, 51, 63, 51, 51, 51], [30, 12, 12, 12, 12, 12, 30], [120, 48, 48, 48, 51, 51, 30], [103, 102, 54, 30, 54, 102, 103], [15, 6, 6, 6, 70, 102, 127], [99, 119, 127, 127, 107, 99, 99], [99, 103, 111, 123, 115, 99, 99], [28, 54, 99, 99, 99, 54, 28], [63, 102, 102, 62, 6, 6, 15], [30, 51, 51, 51, 59, 30, 56], [63, 102, 102, 62, 54, 102, 103], [30, 51, 7, 14, 56, 51, 30], [63, 45, 12, 12, 12, 12, 30], [51, 51, 51, 51, 51, 51, 63], [51, 51, 51, 51, 51, 30, 12], [99, 99, 99, 107, 127, 119, 99], [99, 99, 54, 28, 28, 54, 99], [51, 51, 51, 30, 12, 12, 30], [127, 99, 49, 24, 76, 102, 127], [30, 6, 6, 6, 6, 6, 30], [3, 6, 12, 24, 48, 96, 64], [30, 24, 24, 24, 24, 24, 30], [8, 28, 54, 99, , , ,], [, , , , , , , 255], [12, 12, 24, , , , ,], [, , 30, 48, 62, 51, 110], [7, 6, 6, 62, 102, 102, 59], [, , 30, 51, 3, 51, 30], [56, 48, 48, 62, 51, 51, 110], [, , 30, 51, 63, 3, 30], [28, 54, 6, 15, 6, 6, 15], [, , 110, 51, 51, 62, 48, 31], [7, 6, 54, 110, 102, 102, 103], [12, , 14, 12, 12, 12, 30], [48, , 48, 48, 48, 51, 51, 30], [7, 6, 102, 54, 30, 54, 103], [14, 12, 12, 12, 12, 12, 30], [, , 51, 127, 127, 107, 99], [, , 31, 51, 51, 51, 51], [, , 30, 51, 51, 51, 30], [, , 59, 102, 102, 62, 6, 15], [, , 110, 51, 51, 62, 48, 120], [, , 59, 110, 102, 6, 15], [, , 62, 3, 30, 48, 31], [8, 12, 62, 12, 12, 44, 24], [, , 51, 51, 51, 51, 110], [, , 51, 51, 51, 30, 12], [, , 99, 107, 127, 127, 54], [, , 99, 54, 28, 54, 99], [, , 51, 51, 51, 62, 48, 31], [, , 63, 25, 12, 38, 63], [56, 12, 12, 7, 12, 12, 56], [24, 24, 24, , 24, 24, 24], [7, 12, 12, 56, 12, 12, 7], [110, 59, , , , , ,]];
2211+
function o(e, y = {}) {
2212+
let p = e.text, f = e.textsize, b = e.textalign, d = { chars: u, first: 33, size: 8 }, n = 1, t = null, v = (a) => {
2213+
n = Math.round(a / t.size);
2214+
}, h = () => console.warn("textalign() xxx has not yet been implemented for pixel font"), g = (a, c, x, l = 3) => {
2215+
let m = x.charCodeAt(0), r = t.chars[m - t.first];
2216+
if (r) for (let s = 0; s < t.size; s++) for (let i = 0; i < t.size; i++) (r[s] | 0) & 1 << i && e.rectfill(a + i * n, c + s * n, n, n, l);
2217+
}, w = (a, c, x, l = 3) => {
2218+
x += "";
2219+
let m = n * t.size;
2220+
for (let r = 0; r < x.length; r++) g(a, c, x[r], l), a += m;
2221+
};
2222+
return { PIXEL_FONT_BASIC: d, textfont: (a) => {
2223+
typeof a == "object" ? (e.def("text", w), e.def("textsize", v), e.def("textalign", h), t = a) : (e.def("text", p), e.def("textsize", f), e.def("textalign", b), t = null);
2224+
} };
2225+
}
2226+
window.pluginPixelFont = o;
2227+
})();
22092228
})();
22102229
/*! @litecanvas/utils by Luiz Bills | MIT Licensed */
22112230
/*! Asset Loader plugin for litecanvas by Luiz Bills | MIT Licensed */

public/preview.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
instance.use(pluginFrameRateMeter, {
9797
hidden: false,
9898
});
99+
instance.use(pluginPixelFont);
99100
instance.listen("before:init", () => {
100101
instance.use(pluginAssetLoader);
101102
});

script/copy-files.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ const pluginFrameRateMeter = await readFile(
3838

3939
await appendFile(engineFile, "\n" + pluginFrameRateMeter);
4040

41+
const pluginPixelFont = await readFile(
42+
root + "/node_modules/@litecanvas/plugin-pixel-font/dist/dist.js",
43+
{ encoding: "utf8" }
44+
);
45+
46+
await appendFile(engineFile, "\n" + pluginPixelFont);
47+
4148
await esbuild.build({
4249
entryPoints: [engineFile],
4350
outfile: engineFile,

0 commit comments

Comments
 (0)