# sdf-manager

> Load, parse, and cache MapLibre glyph SDFs, and construct glyph atlases

Latest version **0.0.10** (published 2021-09-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install sdf-manager
pnpm add sdf-manager
yarn add sdf-manager
bun add sdf-manager
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10 |
| Published | 2021-09-03 |
| First published | 2020-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jeshurun Hembd |
| Maintainers | jjhembd |
| Keywords | text, glyph, sdf, atlas |

## Links

- npm: https://www.npmjs.com/package/sdf-manager
- Repository: https://github.com/GlobeletJS/sdf-manager
- Homepage: https://github.com/GlobeletJS/sdf-manager#readme
- Issues: https://github.com/GlobeletJS/sdf-manager/issues
- npm.io page: https://npm.io/package/sdf-manager

## Dependencies (1)

- [potpack](https://npm.io/package/potpack.md) ^1.0.1

## Alternatives

- [ext-list](https://npm.io/package/ext-list.md) — 6.3M weekly downloads
- [@lexical/selection](https://npm.io/package/@lexical/selection.md) — 3.8M weekly downloads
- [@lexical/text](https://npm.io/package/@lexical/text.md) — 3.6M weekly downloads
- [@lexical/clipboard](https://npm.io/package/@lexical/clipboard.md) — 3.0M weekly downloads
- [@tiptap/extension-mention](https://npm.io/package/@tiptap/extension-mention.md) — 3.0M weekly downloads

## Recent versions

- 0.0.10 (latest) — 2021-09-03
- 0.0.9 — 2021-07-22
- 0.0.8 — 2021-07-06
- 0.0.7 — 2021-07-02
- 0.0.6 — 2020-11-14
- 0.0.5 — 2020-08-07
- 0.0.4 — 2020-07-31
- 0.0.3 — 2020-07-14
- 0.0.2 — 2020-06-17
- 0.0.1 — 2020-06-17

## README

# sdf-manager

Load, parse, and cache MapLibre glyph SDFs, and construct glyph atlases

The code follows the same strategy as the glyph management in
[MapLibre-GL](https://github.com/maplibre/maplibre-gl-js).
sdf-manager simply pulls out this part of the code and modularizes it.

![tests](https://github.com/GlobeletJS/sdf-manager/actions/workflows/node.js.yml/badge.svg)

## Installation
vector-map is provided as an ESM import
```javascript
import * as sdfManager from 'sdf-manager';
```

## Syntax
```javascript
const getGlyphs = sdfManager.initGetter(urlTemplate, key);
```

The `urlTemplate` must follow the pattern described in the
[MapLibre documentation](https://maplibre.org/maplibre-gl-js-docs/style-spec/glyphs/).
The `key` is your API key to access the SDF server.

The returned `getGlyphs` function has the following syntax:
```javascript
const atlas = getGlyphs(fonts);
```
where `fonts` is a dictionary of fonts and associated character codes, with 
the following structure:
```javascript
const fonts = { font1: [code1, code2, ...], font2: [...], ... };
```

Examples of the returned `atlas`, and how it can be used, can be found in this
[Observable notebook](https://observablehq.com/@jjhembd/mapbox-glyph-pbfs#atlas_documentation)

## References
- [Valve's paper on SDF for text rendering](https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf)
- [Konstantin Käfer's application to map labels](https://blog.mapbox.com/drawing-text-with-signed-distance-fields-in-mapbox-gl-b0933af6f817)
- [mapbox-gl-native text rendering documentation](https://github.com/mapbox/mapbox-gl-native/wiki/Text-Rendering)

---
_Source: https://npm.io/package/sdf-manager · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
