{"name":"@mapbox/tiny-sdf","version":"1.0.2","description":"Browser-side SDF font generator","main":"index.js","scripts":{"test":"eslint index.js"},"repository":{"type":"git","url":"git+https://github.com/mapbox/tiny-sdf.git"},"keywords":["sdf","signed distance fields","font","canvas","text","distance transform"],"author":{"name":"Vladimir Agafonkin"},"license":"ISC","bugs":{"url":"https://github.com/mapbox/tiny-sdf/issues"},"homepage":"https://github.com/mapbox/tiny-sdf#readme","devDependencies":{"eslint":"^3.12.0","eslint-config-mourner":"^2.0.1"},"eslintConfig":{"extends":"mourner"},"gitHead":"da3cde4753f348612e0f0bfe48f999c8a6de6b63","_id":"@mapbox/tiny-sdf@1.0.2","_shasum":"7b41ce7b2cfcf8b5bda4e62a49aa22d45455acbc","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.3.0","_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"dist":{"shasum":"7b41ce7b2cfcf8b5bda4e62a49aa22d45455acbc","tarball":"http://registry-npm.ywwl.com/@mapbox/tiny-sdf/download/@mapbox/tiny-sdf-1.0.2.tgz","integrity":"sha512-kzHc60iNkxs/EfCIUkx7N18ccAluqEibC01ehzXBUSld7YTG/khYLXoEdH4GO4ydwtxusG3LTtLNGiCGgciVYQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBHGYEBqomz/idL6L5iynWKNP73yjG4ro3Sd1gwzhzJ6AiABQfIBopOhWqTs+3tkNn5cPF8j15K9ZbJfmpDayW5i3A=="}],"size":17106,"noattachment":false,"key":"/@mapbox/tiny-sdf/-/@mapbox/tiny-sdf-1.0.2.tgz"},"maintainers":[{"name":"mourner","email":"agafonkin@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/tiny-sdf-1.0.2.tgz_1482513179982_0.2504809161182493"},"directories":{},"readme":"# TinySDF [![Build Status](https://travis-ci.com/mapbox/tiny-sdf.svg?branch=main)](https://travis-ci.com/mapbox/tiny-sdf)\n\nTinySDF is a tiny and fast JavaScript library for generating SDF (signed distance field)\nfrom system fonts on the browser using Canvas 2D and\n[Felzenszwalb/Huttenlocher distance transform](https://cs.brown.edu/~pff/papers/dt-final.pdf).\nThis is very useful for [rendering text with WebGL](https://www.mapbox.com/blog/text-signed-distance-fields/).\n\n## [Demo](http://mapbox.github.io/tiny-sdf)\n\n## Usage\n\nCreate a TinySDF for drawing glyph SDFs based on font parameters:\n\n```js\nconst tinySdf = new TinySDF({\n    fontSize: 24,             // Font size in pixels\n    fontFamily: 'sans-serif', // CSS font-family\n    fontWeight: 'normal',     // CSS font-weight\n    fontStyle: 'normal',      // CSS font-style\n    buffer: 3,                // Whitespace buffer around a glyph in pixels\n    radius: 8,                // How many pixels around the glyph shape to use for encoding distance\n    cutoff: 0.25              // How much of the radius (relative) is used for the inside part of the glyph\n});\n\nconst glyph = tinySdf.draw('泽'); // draw a single character\n```\n\nReturns an object with the following properties:\n\n- `data` is a `Uint8ClampedArray` array of alpha values (0–255) for a `width` x `height` grid.\n- `width`: Width of the returned bitmap.\n- `height`: Height of the returned bitmap.\n- `glyphTop`: Maximum ascent of the glyph from alphabetic baseline.\n- `glyphLeft`: Currently hardwired to 0 (actual glyph differences are encoded in the rasterization).\n- `glyphWidth`: Width of the rasterized portion of the glyph.\n- `glyphHeight` Height of the rasterized portion of the glyph.\n- `glyphAdvance`: Layout advance.\n\nTinySDF is provided as a ES module, so it's only supported on modern browsers, excluding IE.\n\n```html\n<script type=\"module\">\nimport TinySDF from 'https://cdn.skypack.dev/@mapbox/tiny-sdf';\n...\n</script>\n```\n\nIn Node, you can't use `require` — only `import` in ESM-capable versions (v12.15+):\n\n```js\nimport TinySDF from '@mapbox/tiny-sdf';\n```\n\n## Development\n\n```bash\nnpm test  # run tests\nnpm start # start server for the demo page\n```\n\n## License\n\nThis implementation is licensed under the [BSD 2-Clause license](https://opensource.org/licenses/BSD-2-Clause). It's based directly on the algorithm published in the Felzenszwalb/Huttenlocher paper, and is not a port of the existing C++ implementation provided by the paper's authors.\n","publish_time":1482513182362,"_cnpm_publish_time":1482513182362,"dist-tags":{"latest":"2.3.0"}}