Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

text2matrix

TheSnowyxGIT143ISC2.0.0TypeScript support: included

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

pixel, font, matrix, typography, rasterize, text-to-pixel, LED-display, text-rendering, font-rendering, canvas, webfonts, pixel-art, bitmap-font, pixel-font, font-conversion, text-visualization, letter-spacing, character-map, text-matrix, typeface

readme

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
}

changelog

text2matrix

2.0.0

Major Changes

  • 55c566f: refactor all upgrade Font class add Text class handle font ascender / descender / etc

1.1.10

Patch Changes

  • ae1763d: add normalisation of font size

1.1.9

Patch Changes

  • cd73e02: upadte constructor

1.1.8

Patch Changes

  • 4c8ba2c: refactor

1.1.7

Patch Changes

  • a06e422: add getFont

1.1.6

Patch Changes

  • d2303b2: switch from buffer to ArrayBuffer

1.1.4

Patch Changes

  • 531bac4: try to make available for browser

1.1.3

Patch Changes

  • 0fe9f7d: add platform compatibility for nodejs and browser

1.1.2

Patch Changes

  • 2df3e47: export getFileHash

1.1.1

Patch Changes

  • 2ad69a5: fix addFont to allow known hash

1.1.0

Minor Changes

  • b21abd3: fonts storage by hash sha256 allow loading fonts by Buffers

1.0.3

Patch Changes

  • fd3154c: fix estimateFontSize

1.0.2

Patch Changes

  • e76f9b4: fix build

1.0.1

Patch Changes

  • 052dd7b: add ReadMe