Production-ready minified bundles for BitmapText.js bitmap text rendering library.
bitmaptext.js - Unminified runtime (149KB, for debugging)bitmaptext.min.js - Minified runtime (32KB, for production) β¨bitmaptext.min.js.map - Source map for debugging minified codebitmaptext-node.js - Unminified runtime (153KB, for debugging)bitmaptext-node.min.js - Minified runtime (33KB, for production) β¨bitmaptext-node.min.js.map - Source map for debugging minified code<!DOCTYPE html>
<html>
<head>
<title>BitmapText Demo</title>
</head>
<body>
<canvas id="myCanvas" width="400" height="100"></canvas>
<!-- Single script tag - complete runtime -->
<script src="dist/bitmaptext.min.js"></script>
<script>
// Create font configuration
const fontProps = new FontProperties(
1, // pixelDensity (1.0 = standard, 2.0 = Retina)
"Arial", // fontFamily
"normal", // fontStyle
"normal", // fontWeight
19 // fontSize in CSS pixels
);
// Optional: Configure font directory
BitmapText.setFontDirectory('./font-assets/');
// Load font and render
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
BitmapText.loadFont(fontProps.idString).then(() => {
BitmapText.drawTextFromAtlas(ctx, "Hello World", 10, 50, fontProps);
});
</script>
</body>
</html>
The Node.js bundle excludes platform-specific dependencies. You must provide your own Canvas implementation.
// Import Canvas implementation (user's choice)
import { createCanvas } from 'node-canvas'; // or 'skia-canvas', 'canvas', etc.
// Import BitmapText bundle
import './dist/bitmaptext-node.min.js';
// Configure with your Canvas
BitmapText.configure({
fontDirectory: './font-assets/',
canvasFactory: () => createCanvas()
});
// Create font configuration
const fontProps = new FontProperties(1, "Arial", "normal", "normal", 19);
// Load font and render
await BitmapText.loadFont(fontProps.idString);
const canvas = createCanvas(400, 100);
const ctx = canvas.getContext('2d');
BitmapText.drawTextFromAtlas(ctx, "Hello World", 10, 50, fontProps);
// Export canvas (requires separate PNG encoder)
import { PngEncoder } from './lib/PngEncoder.js';
import fs from 'fs';
fs.writeFileSync('output.png', PngEncoder.encode(canvas));
The bundles contain everything needed for rendering bitmap text:
The browser bundle is complete for text rendering. No additional dependencies needed.
You must provide separately:
node-canvas - Native Canvas API for Node.js (most popular)skia-canvas - Hardware-accelerated alternativecanvas - Pure JavaScript Canvas implementationlib/PngEncoder.js - Included in demo bundles but separate from library| Bundle | Unminified | Minified | Reduction |
|---|---|---|---|
| Browser | 149KB | 32KB | 79% |
| Node.js | 153KB | 33KB | 79% |
Note: Font asset files are separate (metrics ~1-2KB each, atlases ~2-5KB each).
Rebuild everything (recommended):
npm run build
# or
./scripts/build-runtime-bundle.sh --all
Rebuild specific bundles:
# Browser bundle only
./scripts/build-runtime-bundle.sh --browser
# or
npm run build-bundle
# Node.js bundle only
./scripts/build-runtime-bundle.sh --node
# or
npm run build-bundle-node
| Command | Browser Bundle | Node.js Bundle | Output |
|---|---|---|---|
npm run build |
β | β | Both bundles + source maps |
npm run build-bundle |
β | β | Browser only |
npm run build-bundle-node |
β | β | Node.js only |
./scripts/build-runtime-bundle.sh |
β | β | Browser (default) |
./scripts/build-runtime-bundle.sh --all |
β | β | Both bundles |
Each build creates:
Rebuild bundles after modifying any runtime source files:
src/runtime/*.js - Core runtime classessrc/platform/FontLoader-*.js - Font loadingsrc/builder/MetricsExpander.js - Metrics expansionlib/QOIDecode.js - QOI decoder (Node.js only)Browser (open in browser):
npm run serve
# Then open http://localhost:8000/public/hello-world-demo-bundled.html
Node.js (run all demos):
./run-node-demos.sh
This builds bundles, runs 4 demos, and generates PNG output to verify everything works.
See the bundled demo files for complete working examples:
public/hello-world-demo-bundled.html - Basic single-size demopublic/hello-world-multi-size-bundled.html - Multi-size font loadingpublic/baseline-alignment-demo-bundled.html - Interactive baseline/alignment demopublic/test-renderer-bundled.html - Full test suite with hash verificationThe minified bundles include source maps for debugging:
<!-- Browser DevTools will automatically load the source map -->
<script src="dist/bitmaptext.min.js"></script>
Set breakpoints in original source files, inspect variables, and see readable stack traces.
For development, use the unminified version:
<!-- Easier to debug without source maps -->
<script src="dist/bitmaptext.js"></script>
For maximum debugging flexibility, use the individual source files:
<!-- Original demos load 17 separate files -->
<!-- See public/hello-world-demo.html for example -->
SEE LICENSE IN LICENSE