{"name":"l7-tiny-sdf","version":"0.0.3","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.3","_nodeVersion":"14.16.1","_npmVersion":"8.3.0","dist":{"integrity":"sha512-11y9TXdBAlsbIXtkIUOJHU40aZ4VQGZxbDr8pCqgmhgLlY0WKRdA8fnC1A34SWB/VhNdxW2T80hOvepAL/G8/w==","shasum":"f9cf86c46c1bac2f97a7e2708899184fea4107db","tarball":"http://registry-npm.ywwl.com/l7-tiny-sdf/download/l7-tiny-sdf-0.0.3.tgz","fileCount":6,"unpackedSize":27172,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiDJd8CRA9TVsSAnZWagAALxIQAIRoh2CT88/k8YoqxoBs\nqKwGhB/d4BQ5oyw6reG1M0SiU5QeRvQoWw2crGQ9rzAAspRjxeqOm7q4viuG\nOR99x7aIurbA2ebQTxVoB1VQhoQWoZnYIdMyeU0WWvHmN0G6GJd8/NY3ey0Z\nePz2tPdlX41BpmDxuxRC0fUAh8uKk+UcQP+GjkxPuVFD4NF61YbI6l/Z5Kbd\nlUHt9D8Fq7mFTzY46uYycA6LbJATl/VwLO0I5ekRWplrwkVrPq6koUqkvWEw\nmDAUSLmceY9ZqkHbNYwfnmP9XeAOeesBAy/fAXY6arN4CYgxxQz0tIxGbBOm\nueLa08jwkWuY9rMxyBK9XeMg1Il05qcLfXRLiYGnVoHZ5KBgQSfmHaRnDbDE\nSBmHfur6CVTp7i1RBZJkFar0q/LIiGEAdfAQkhPNFJFfauWNbx4e3Wz44ys+\nZMJh71hgBR4wluShoph7QFS/LOkD3mTx5llW8fw3cRJdNnLxkS63i6Pjmt+9\nMOqMdVk/9tP0/VocUqJeAWIT1cnor+ZChsetqF30Gm1UuPmL8Ir3dKoyDFvh\nzaI+HYI0O4z6shE2xHFZ5zOfRf7z49RwOJmn3110qGln8vAAa0/jFcHBPvYv\n+6NR8Fa0olDhq3UDgPlDL0TdM7KXDEic7O88cSHARc4lWshW+e4q4S3Eg5Hq\nS7AJ\r\n=B2+I\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDPGd4q83SZ8khX8eGpr0Ip3wgT7KPG62etxnWzyV719AiEAmUyxW68mJ0OwgSv75gobE7e3oBXiCgj5kp0yFsLNlKg="}],"size":11307,"noattachment":false,"key":"/l7-tiny-sdf/-/l7-tiny-sdf-0.0.3.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.3_1644992380046_0.9451911499321233"},"_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":1644992380180,"_cnpm_publish_time":1644992380180,"dist-tags":{"latest":"0.0.4"}}