@thi.ng/webgl-msdf
Version:
Multi-channel SDF font rendering & basic text layout for WebGL
116 lines (82 loc) • 4.59 kB
Markdown
<!-- This file is generated - DO NOT EDIT! -->
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
# 
[](https://www.npmjs.com/package/@thi.ng/webgl-msdf)

[](https://mastodon.thi.ng/@toxi)
> [!NOTE]
> This is one of 210 standalone projects, maintained as part
> of the [.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
> and anti-framework.
>
> 🚀 Please help me to work full-time on these projects by [sponsoring me on
> GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
- [About](#about)
- [Status](#status)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [Usage examples](#usage-examples)
- [API](#api)
- [Authors](#authors)
- [License](#license)
## About
Multi-channel SDF font rendering & basic text layout for WebGL. This is a support package for [.ng/webgl](https://github.com/thi-ng/umbrella/tree/develop/packages/webgl).
This package provides [multi-channel SDF font
rendering](https://github.com/Chlumsky/msdfgen) capabilities for
[.ng/webgl](https://github.com/thi-ng/umbrella/tree/develop/packages/webgl),
incl. optional support for basic text alignment, vertex colors (e.g. for
multi-color text), and shader options to draw outlines for each
character. Furthermore, the key GLSL functions are provided as shader
snippets to embed this functionality in custom shaders without having to
resort to copy & paste.
There're different versions of MSDF font generators. The format
supported by this module is based on [Don
McCurdy's](https://msdf-bmfont.donmccurdy.com/).
## Status
**STABLE** - used in production
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bwebgl-msdf%5D+in%3Atitle)
## Installation
```bash
yarn add .ng/webgl-msdf
```
ESM import:
```ts
import * as wm from "@thi.ng/webgl-msdf";
```
Browser ESM import:
```html
<script type="module" src="https://esm.run/@thi.ng/webgl-msdf"></script>
```
[JSDelivr documentation](https://www.jsdelivr.com/)
Package sizes (brotli'd, pre-treeshake): ESM: 1.57 KB
## Dependencies
- [.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
- [.ng/shader-ast](https://github.com/thi-ng/umbrella/tree/develop/packages/shader-ast)
- [.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
- [.ng/vector-pools](https://github.com/thi-ng/umbrella/tree/develop/packages/vector-pools)
- [.ng/vectors](https://github.com/thi-ng/umbrella/tree/develop/packages/vectors)
- [.ng/webgl](https://github.com/thi-ng/umbrella/tree/develop/packages/webgl)
Note: .ng/api is in _most_ cases a type-only import (not used at runtime)
## Usage examples
One project in this repo's
[/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
directory is using this package:
| Screenshot | Description | Live demo | Source |
|:------------------------------------------------------------------------------------------------------------------|:--------------------------------------------|:-------------------------------------------------|:------------------------------------------------------------------------------|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-msdf.jpg" width="240"/> | WebGL MSDF text rendering & particle system | [Demo](https://demo.thi.ng/umbrella/webgl-msdf/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-msdf) |
## API
[Generated API docs](https://docs.thi.ng/umbrella/webgl-msdf/)
TODO
## Authors
- [Karsten Schmidt](https://thi.ng)
If this project contributes to an academic publication, please cite it as:
```bibtex
{thing-webgl-msdf,
title = "@thi.ng/webgl-msdf",
author = "Karsten Schmidt",
note = "https://thi.ng/webgl-msdf",
year = 2019
}
```
## License
© 2019 - 2025 Karsten Schmidt // Apache License 2.0