Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 669 Bytes

README.md

File metadata and controls

26 lines (19 loc) · 669 Bytes

Text2Matrix

Introduction

Convert text strings into customizable pixel matrices with options for max height, letter spacing, and more. Ideal for LED displays and creative typographic applications.

Installation

npm install text2matrix

Usage

const { Font, Text } = require("text2matrix");

async function main() {
  const text = "Hello World!";
  const myFont = "myFont.ttf";
  const font = await Font.fromPath(myFont);
  const text = new Text(text, font, { fontSize: 16 });
  text.draw(); // only node environment, creates a png file
  const matrix = text.matrix; // returns a 2D array of grayscale values between 0 and 1
}