Typography is the By Sages typography toolkit: Unicode-aware text security, unified OCR across system and AI engines, and font engineering for parsing, rendering, creation, and subsetting — one set of composable packages with runtime-neutral TypeScript APIs.
⭐ If Typography is useful to you, a star helps other developers find it.
- 🔐 Text that can be checked —
unconfusablesimplements Unicode Security Mechanisms with confusable skeletons, intentional-confusable detection, identifier profiling, script analysis, and restriction levels. - 🧠 One OCR contract —
unocrnormalizes image input and results, then lets you swap system OCR, Tesseract CLI, Tesseract.js, browser Shape Detection, or an AI vision model without changing application code. - 🔤 Fonts without a bespoke pipeline —
unglyphreads font metadata, glyphs, variation axes, and color-format capabilities; renders glyphs; writes TrueType and CFF-based OpenType; and subsets with HarfBuzz. - 🌍 Same code across runtimes — core APIs are typed ESM designed for Node and modern browsers, with platform-specific engines isolated behind optional drivers or optional rendering dependencies.
- 🧩 Composable by design — each package solves one part of the typography stack, so a security audit, an OCR service, and a font tool can share the same foundation without pulling in the rest.
| Package | Version | Description |
|---|---|---|
| unconfusables | Unicode confusables, identifier profiling, and script analysis | |
| unocr | Unified OCR with native, CLI, browser, WASM, and AI drivers | |
| unglyph | Font parsing, rendering, creation, metadata, and subsetting |
Install the package for the task:
pnpm add unconfusables
# or unocr / unglyphCheck whether text relies on visually confusable characters:
import { areConfusable, detectConfusables, skeleton } from "unconfusables";
skeleton("pa\u200Bypal"); // "paypal"
areConfusable("paypal", "paypa1"); // true
detectConfusables("g00gle");Recognize text with the best OCR backend available on the current host:
import { createOCRManager } from "unocr";
import autoDriver from "unocr/drivers/auto";
const ocr = createOCRManager({ driver: autoDriver() });
const result = await ocr.recognize(image);
await ocr.dispose();Parse and render a font, or turn glyph paths back into a font file:
import { createFont, generateFont, parseFont, renderGlyphToSVG } from "unglyph";
const source = await parseFont(fontBytes);
const glyph = source.glyphs.find((item) => item.unicode === 65);
const svg = renderGlyphToSVG(glyph, { size: 64 });
const font = createFont(glyphs, { familyName: "Example", styleName: "Regular" });
const bytes = await generateFont(font, { format: "ttf" });- Node.js 20.x or higher
- pnpm 10.x or higher
- Git for version control
-
Clone the repository:
git clone https://github.com/bysages/typography.git cd typography -
Install dependencies and build packages:
pnpm install
-
Start from a playground when you want to explore a package:
pnpm dev
pnpm build # Build every package
pnpm check # Format, lint, and type check
pnpm test # Run all tests
pnpm release # Run package release tasksThe playground/ directory keeps runnable examples for each package; use those examples as integration checks while changing parser, driver, or Unicode-data behavior.
This project follows Semantic Versioning. While the major version is 0 (pre-1.0), breaking API changes are released as minor version bumps (0.x.0) rather than patch releases — the public API is expected to keep evolving until the 1.0.0 stabilization release. Pin exact versions in downstream projects if you require stability between minor updates.
We welcome contributions! Use conventional commits (feat:, fix:, and related types), add or update tests for behavior changes, and run pnpm check and pnpm test before submitting a pull request.
If Typography is useful to you, a ⭐ star helps other developers find it.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ by By Sages