{"name":"l7-tiny-sdf","version":"0.0.1","description":"Browser-side SDF font generator","main":"index.js","scripts":{"test":"eslint index.js"},"keywords":["sdf","signed distance fields","font","canvas","text","distance transform"],"author":"","license":"BSD-2-Clause","devDependencies":{"eslint":"^7.0.0","eslint-config-mourner":"^2.0.1"},"eslintConfig":{"extends":"mourner"},"_id":"l7-tiny-sdf@0.0.1","_nodeVersion":"14.16.1","_npmVersion":"7.20.1","dist":{"integrity":"sha512-sPTrTMNRT164KyeY+Kj6IhccjGHi1VRN81BsvQxMj/jWwH1tSbjO7RyAKRcEp4cWPpVOXZ1kdyAl2aIOCD9Jfw==","shasum":"47bf1cd65501900f60b30f9d4255be78b76c5b52","tarball":"http://registry-npm.ywwl.com/l7-tiny-sdf/download/l7-tiny-sdf-0.0.1.tgz","fileCount":6,"unpackedSize":27059,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhFM8lCRA9TVsSAnZWagAA0CYP/iPsKfH6/Dg+tfC5Cj07\nyQ9i4uR5wsYD3p3ZXlLikCTk9GNnlnuKg5ZiXV24rd633aWRxZiFDpR39Hxq\ngU4ZqQhd4QlhWh8JXnedGV0iQjCYS+YIvePS7CsbuGqmXMmXAsUOylnyDnDm\nNOoDUZXtVaZ09dAY5D0GFlxjkO3QwKhlgWriJ+b1Gm4uJF9izqeH0TWAtudt\nA0bPcco/+2WIdoMjRLoTNpJHzPNXtx33GSGahjZ8zYVSQQBAjpj8NAKEHysp\nIeRjp1ZvK/mDR0KRTgUp2RzoJYVlnqXS+AyMXF9wh3rl7ZG2KSojOgjU3Z5w\nSGeob6QaKabmRHSTraVcwSYIzx1TRGgdwjORYREWDohDoBaqXaESbXqFrSC8\nhs0V646/cmFXYXmFzj2nHmxkgZNZ2Go9S96Iqjul1nfYOeIZv7s5y4id1jvJ\nGjAC2GlBdZ6birsPyXhEM8/2CwLZzzB8eDKA6tpuEAxRp0+Zz6LmCWO5kwXA\n3jK/amyU2aInCe0REtRwWiXq1lPJbrTXQBzFK8kIgd32Y508jqUdNWrK1UXl\ndVOpvsoVewMANVNrabh/xbDUD/3Bh/G9sQcBpWkzL91JZa5nHK3FxxkPbYPh\nlmmx1Piqb5uZ00MbYxQJh0oxmUcnoRlzbHmaMvtUR/Dcy5elOaDrBLsq+L5B\nljWg\r\n=zEhN\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHKETzFfVtiU2fhrGX1jYoQ7Tp4QrwEAHyD7K3kQMPS+AiB4pcs3zWLEpeUVQK7EQWzhr9hqNhvCW3PKejtcAJV/zw=="}],"size":11283,"noattachment":false,"key":"/l7-tiny-sdf/-/l7-tiny-sdf-0.0.1.tgz"},"_npmUser":{"name":"yiqianyao","email":"2912401452@qq.com"},"directories":{},"maintainers":[{"name":"yiqianyao","email":"2912401452@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/l7-tiny-sdf_0.0.1_1628753700945_0.2077325769683802"},"_hasShrinkwrap":false,"readme":"# TinySDF\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\nThis implementation is 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\nDemo: http://mapbox.github.io/tiny-sdf/\n\n## Usage\nCreate a TinySDF for drawing SDFs based on font parameters:\n\n```js\nvar fontsize = 24; // Font size in pixels\nvar buffer = 3;    // Whitespace buffer around a glyph in pixels\nvar radius = 8;    // How many pixels around the glyph shape to use for encoding distance\nvar cutoff = 0.25  // How much of the radius (relative) is used for the inside part the glyph\n\nvar fontFamily = 'sans-serif'; // css font-family\nvar fontWeight = 'normal';     // css font-weight\nvar tinySDFGenerator = new TinySDF(fontsize, buffer, radius, cutoff, fontFamily, fontWeight);\n\nvar oneSDF = tinySDFGenerator.draw('泽');\n// returns a Uint8ClampedArray array of alpha values (0–255) for a size x size square grid\n\n// To generate glyphs with variable advances (e.g. non-ideographic glyphs),\n// use `drawWithMetrics`\nvar sdfWithMetrics = tinySDFGenerator.drawWithMetrics('A');\n// sdfWithMetrics.data is the same as in `draw`, except the size may be clipped to fit the glyph\n// sdfWithMetrics.metrics contains:\n//  top:        Maximum ascent of glyph from alphabetic baseline\n//  left:       Currently hardwired to 0 (actual glyph differences are encoded in the rasterization)\n//  width:      Width of rasterized portion of glyph\n//  height\n//  advance:    Layout advance\n//  sdfWidth:   Width of the returned bitmap, usually but not always width + 2 * buffer\n//  sdfHeight\n```\n","publish_time":1628753701120,"_cnpm_publish_time":1628753701120,"dist-tags":{"latest":"0.0.4"}}