# fontpath-shape2d

> Decomposes vector font into discrete points

Latest version **0.0.5** (published 2014-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install fontpath-shape2d
pnpm add fontpath-shape2d
yarn add fontpath-shape2d
bun add fontpath-shape2d
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2014-07-06 |
| First published | 2014-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | fontpath, font, vector, path, outline, decompose, glyph, ttf, otf, woff |

## Links

- npm: https://www.npmjs.com/package/fontpath-shape2d
- Repository: https://github.com/mattdesl/fontpath-shape2d
- Issues: https://github.com/mattdesl/fontpath-shape2d/issues
- npm.io page: https://npm.io/package/fontpath-shape2d

## Dependencies (1)

- [shape2d](https://npm.io/package/shape2d.md) 0.0.5

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.0.5 (latest) — 2014-07-06
- 0.0.4 — 2014-07-06
- 0.0.3 — 2014-07-06
- 0.0.2 — 2014-05-19
- 0.0.1 — 2014-05-06

## README

# about

Decompose a glyph outline generated from [fontpath](https://github.com/mattdesl/fontpath) into a discrete set of points, using [shape2d](https://github.com/mattdesl/shape2d).

The curve/bezier approximation and simplification algorithms are very crude, but performant and sufficient for simple output.

# example

```js
//Get the data from fontpath tool 
var Lato = require('./myfonts/Lato-Bold.ttf.json');

var decompose = require('fontpath-shape2d');

//decompose a glyph
var glyph = Lato.glyphs["b"];
var shapes = decompose(glyph, {
	steps: 20
});

//Returns a list of shapes, e.g. the dot and stem of 'i' 
for (var i=0; i < shapes.length; i++) {
	var s = shapes[i];

	//Each shape has a list of points, as Vector2 objects
	for (var j=0; j < s.points.length; j++) {
		var p = s.points[j];

		//...
	}
}
```

# demo

For a complete example, see the [demo](demo/main.js). You can run it with beefy:

```bash
cd fontpath-shape2d

#install the tools globally
npm install beefy browserify -g

#install our dependencies
npm install

#now run the demo
beefy demo/main.js
```

Result:  
![Output](http://i.imgur.com/1M4UAnz.png)

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