{"name":"l7-tiny-sdf","version":"0.0.2","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.2","_nodeVersion":"14.16.1","_npmVersion":"7.20.1","dist":{"integrity":"sha512-Fde4Pq9jycqi3d11I1MfbTISimfCzmEyhq5FhrnbNu9y1BFyCJFxSHbzehmRaYgQPbL4kpI3ldkHGrrFHs10cA==","shasum":"41a97a179279cbda094e5874c61ad88d10563479","tarball":"http://registry-npm.ywwl.com/l7-tiny-sdf/download/l7-tiny-sdf-0.0.2.tgz","fileCount":6,"unpackedSize":27152,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhGgzJCRA9TVsSAnZWagAA2sMQAJvQjkPWovLLX97ETdFy\nvM6damOYiQzCXVyVyqsJyppHBDZyswYHXgI5z9r2n5Sk+U3FDVHDXeBUGAGd\nasa8N1aIT/NYURfd0vE4Qjgyxr6JXxThuAf2zfoV5E3slgtJ31gfchQKC1eX\nD/fk6rSrWPDdywflD16IPe/zIKMugvYcY0NnwTpr37ER7dJC+tqxSIneT4fB\n+z1ROt7D/XTap0nHxjJkxh7op7GOHgkS8qPHJVlValqNYp1SIBgVp7I7EOjX\nrJ92aG/qoSUaNDFco4dwo+6qTM8ZYh2YeupTBeGtX7DbclnzppEzRJvuLcmw\nj7kxcVpsecwCN5ykgoPRCJzVcTN/hUNHasN1wx8k64AcKnRiAFDUk3fQbUeD\nSYdoX4E/xXx28L115x7zItmHlOM9z0NIaJW3eBsFOCn7t0D92w87N9HnA5mj\nyJ3aRmAhMZ6WDFFL/Y9m/VnLtBclsyTsWYCS1rGxBvdYJdY6NTzDImSXP/+F\nsMvcA/2Z6bTkL0qAo5p7rrZg88OpYydWl9WJA9Mn3QGs/srLmk59IdNzVIFt\nX8PuDalQuB4T1RsgmTIhhuWoX74igz+qgRXlETDNVW8I7qAoG0u/huioMdAD\nzLWXjBvGyllEUiX6wo0x6GB/uxxAi33hoBTF50H3zCBxazIlefScofsMQZUd\noCgg\r\n=esW5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCEt4lhe4pGtkxcJmImOD4JQI80NgT4uv5g9zgNeSe0UgIhAKgEjDgNlQSaG4zpZqDePN9pJjmY+O/rYjJIy2ecdRoc"}],"size":11292,"noattachment":false,"key":"/l7-tiny-sdf/-/l7-tiny-sdf-0.0.2.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.2_1629097161569_0.19540851290625239"},"_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":1629097161685,"_cnpm_publish_time":1629097161685,"dist-tags":{"latest":"0.0.4"}}