{"_id":"@pixi/msdf-bmfont-xml","name":"@pixi/msdf-bmfont-xml","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"@pixi/msdf-bmfont-xml","version":"3.0.0","description":"Creates a BMFont compatible bitmap font of Signed-Distance Fields from a font file","main":"index.js","scripts":{"debug":"cd test/assets/fonts && node --inspect-brk=9229 ../../../cli.js -f json -o font -u -m 512,256 -t msdf -s 42 -r 5 -p 2 --smart-size --pot ../../../assets/fonts/DIN_CB.ttf","test":"npm run test:disk && npm run test:memory","test:disk":"cd test/assets/fonts && node ../../../cli.js -f xml -o DIN_CB -v -u -m 512,256 -t msdf -s 42 -r 4 -p 2 --smart-size --pot ../../../assets/fonts/DIN_CB.ttf","test:memory":"node test/test_memory.js","test:rtl":"cd test/assets/fonts && node ../../../cli.js -f xml -o Iransans -i ../../../assets/charset/charset.persian.txt -v -u -m 512,256 -t msdf -s 42 -r 4 -p 2 --smart-size --pot ../../../assets/fonts/Iransans.ttf","test:save":"cd test/assets/fonts && node ../../../cli.js -o DIN_CB -u -m 512,256 --smart-size --pot ../../../assets/fonts/DIN_CB.ttf","test:reuse":"cd test/assets/fonts && node --inspect-brk=9229 ../../../cli.js -u DIN_CB.cfg ../../../assets/fonts/FiraSansMedium.woff","render":"npm run test:disk && node test/test.js"},"bin":{"msdf-bmfont":"cli.js"},"author":{"name":"YM Shen","email":"soimy@163.com","url":"https://github.com/soimy"},"keywords":["bmfont","bitmap","font","text","fonts","signed","distance","field","glyph","glyphs","sdf","msdf","multichannel"],"repository":{"type":"git","url":"git://github.com/pixijs/msdf-bmfont-xml.git"},"homepage":"https://github.com/pixijs/msdf-bmfont-xml","bugs":{"url":"https://github.com/pixijs/msdf-bmfont-xml/issues"},"license":"MIT","dependencies":{"arabic-persian-reshaper":"^1.0.1","cli-progress":"^3.12.0","commander":"^14.0.0","handlebars":"^4.7.7","is-invalid-path":"^1.0.2","jimp":"^1.6.0","js2xmlparser":"^5.0.0","map-limit":"0.0.1","maxrects-packer":"^2.7.3","opentype.js":"^0.11.0"},"devDependencies":{"open":"^10.1.2","rimraf":"^6.0.1","run-parallel":"^1.2.0","serve-handler":"^6.1.6","typescript":"^3.9.10"},"_id":"@pixi/msdf-bmfont-xml@3.0.0","gitHead":"cbf9d25f1e6749bbcfd5b1f1940f614a7cb30634","_nodeVersion":"24.2.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-h/FDfBnWiv4+5JNNsfYs3wpDYYOJCCd14PMbFpt1sHDfutJGZ6MvDvq5JI7pL6toX25uyGPV9ADMCdV1KCVulg==","shasum":"a983b2bbf84f01a201d0e1a7fd72d5f054ec4343","tarball":"https://registry.npmjs.org/@pixi/msdf-bmfont-xml/-/msdf-bmfont-xml-3.0.0.tgz","fileCount":20,"unpackedSize":16610846,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHuQNCpoegCkforT8DYDZvHtr4qPJsvkWtmM6VX7cRhwAiEA7mev6ILO6O98jLNH46NCgMRrcP2zedvQX+BqWxJeOYQ="}]},"_npmUser":{"name":"zyie","email":"sean-burns@outlook.com","actor":{"name":"zyie","email":"sean-burns@outlook.com","type":"user"}},"directories":{},"maintainers":[{"name":"bigtimebuddy","email":"matt@mattkarl.com"},{"name":"zyie","email":"sean-burns@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/msdf-bmfont-xml_3.0.0_1752151129255_0.398779907536456"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-10T12:38:49.142Z","3.0.0":"2025-07-10T12:38:49.571Z","modified":"2025-07-10T12:38:49.845Z"},"maintainers":[{"name":"bigtimebuddy","email":"matt@mattkarl.com"},{"name":"zyie","email":"sean-burns@outlook.com"}],"description":"Creates a BMFont compatible bitmap font of Signed-Distance Fields from a font file","homepage":"https://github.com/pixijs/msdf-bmfont-xml","keywords":["bmfont","bitmap","font","text","fonts","signed","distance","field","glyph","glyphs","sdf","msdf","multichannel"],"repository":{"type":"git","url":"git://github.com/pixijs/msdf-bmfont-xml.git"},"author":{"name":"YM Shen","email":"soimy@163.com","url":"https://github.com/soimy"},"bugs":{"url":"https://github.com/pixijs/msdf-bmfont-xml/issues"},"license":"MIT","readme":"# msdf-bmfont-xml\n\nConverts a `.ttf` font file into multichannel signed distance fields, then outputs packed spritesheets and an `xml(.fnt}` / `txt(.fnt)` or `json` representation of an AngelCode BMFont file.\n\nSigned distance fields are a method of reproducing vector shapes from a texture representation, popularized in [this paper by Valve](http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf).\nThis tool uses [Chlumsky/msdfgen](https://github.com/Chlumsky/msdfgen) to generate multichannel signed distance fields to preserve corners. The distance fields are created from vector fonts, then rendered into texture pages. A BMFont object is provided for character layout. (See: [BMFont format](http://www.angelcode.com/products/bmfont/doc/file_format.html))\n![Preview image](https://raw.githubusercontent.com/pixijs/msdf-bmfont-xml/master/assets/msdf-bmfont-xml.png)\n\n## Run script to see MSDF font in browser using pixi.js\n\n```bash\nnpm install & npm run render\n```\n\n## Install as CLI\n\n```bash\nnpm install msdf-bmfont-xml -g\n```\n\nThen you just need to call `msdf-bmfont` from console to generate font file.\nType in `msdf-bmfont --help` for more detail usage.\n\n![Console-Demo](https://raw.githubusercontent.com/pixijs/msdf-bmfont-xml/master/assets/console-demo.gif)\n\n### Usage\n\n```bash\nUsage: msdf-bmfont [options] <font-file>\n\nCreates a BMFont compatible bitmap font of signed distance fields from a font file\n\nOptions:\n  -V, --version                 output the version number\n  -f, --output-type <format>    font file format: xml(default) | json | txt (default: \"xml\")\n  -o, --filename <atlas_path>   filename of font textures (defaut: font-face)\n                                font filename always set to font-face name\n  -s, --font-size <fontSize>    font size for generated textures (default: 42)\n  -i, --charset-file <charset>  user-specified charactors from text-file\n  -m, --texture-size <w,h>      ouput texture atlas size (default: [2048,2048])\n  -p, --texture-padding <n>     padding between glyphs (default: 1)\n  -b, --border <n>              space between glyphs textures & edge (default: 0)\n  -r, --distance-range <n>      distance range for SDF (default: 4)\n  -t, --field-type <type>       msdf(default) | sdf | psdf (default: \"msdf\")\n  -d, --round-decimal <digit>   rounded digits of the output font file. (default: 0)\n  -v, --vector                  generate svg vector file for debuging\n  -u, --reuse [file.cfg]        save/create config file for reusing settings (default: false)\n      --smart-size              shrink atlas to the smallest possible square\n      --pot                     atlas size shall be power of 2\n      --square                  atlas size shall be square\n      --rot                     allow 90-degree rotation while packing\n      --rtl                     use RTL(Arabic/Persian) charactors fix\n  -h, --help                    output usage information\n```\n\n### CLI Examples\n\nGenerate a multi-channel signed distance field font atlas with ASCII charset, font size 42, spread 3, maximum texture size 512x256, padding 1, and save out config file:\n\n```bash\nmsdf-bmfont --reuse -o path/to/atlas.png -m 512,256 -s 42 -r 3 -p 1 -t msdf path/to/font.ttf\n```\n\nWe will get three file: `atlas.0.png` `atlas.0.cfg` & `font.fnt` and this is the generated atlas in the minimum pot size (256x256):\n\n![Atlas0](https://raw.githubusercontent.com/pixijs/msdf-bmfont-xml/master/assets/atlas.0.png)\n\nThen we want to use the old setting except a different font and use monochrome signed distance field atlas, and output an extra `.svg` version of atlas:\n\n```bash\nmsdf-bmfont -v -u path/to/atlas.0.cfg -t sdf -p 0 -r 8 path/to/anotherfont.ttf\n```\n\nThis time we get a modified `atlas.0.png` with new bitmap font appended:\n\n![Atlas1](https://raw.githubusercontent.com/pixijs/msdf-bmfont-xml/master/assets/atlas.1.jpg)\n\nNot satisfied with the style? Remember we got a `svg` atlas!\n\n![svg](https://raw.githubusercontent.com/pixijs/msdf-bmfont-xml/master/assets/svg.png)\n\nHow about fire up some graphic editor and add some neat effect and lay on the output atlas?\n\n![final](https://raw.githubusercontent.com/pixijs/msdf-bmfont-xml/master/assets/atlas.2.jpg)\n\n## Install as Module\n\n```bash\nnpm install msdf-bmfont-xml\n```\n\n### Module usage Examples\n\nWriting the distance fields and font data to disk:\n\n```js\nconst generateBMFont = require('msdf-bmfont-xml');\nconst fs = require('fs');\n\ngenerateBMFont('Some-Font.ttf', (error, textures, font) => {\n  if (error) throw error;\n  textures.forEach((texture, index) => {\n    fs.writeFile(texture.filename, texture.texture, (err) => {\n      if (err) throw err;\n    });\n  });\n  fs.writeFile(font.filename, font.data, (err) => {\n    if (err) throw err;\n  });\n});\n```\n\nGenerating a single channel signed distance field with a custom character set:\n\n```js\nconst generateBMFont = require('msdf-bmfont');\n\nconst opt = {\n  charset: 'ABC.ez_as-123!',\n  fieldType: 'sdf'\n};\ngenerateBMFont('Some-Font.ttf', opt, (error, textures, font) => {\n  ...\n});\n```\n\n### API\n\n#### `generateBMFont(fontPath | fontBuffer, [opt], callback)`\n\nRenders a bitmap font from the font specified by `fontPath` or `fontBuffer`, with optional `opt` settings, triggering `callback` on complete.\n\nOptions:\n\n- `outputType` (String)\n  - type of output font file. Defaults to `xml`\n    - `xml` a BMFont standard .fnt file which is wildly supported.\n    - `json` a JSON file compatible with [Hiero](https://github.com/libgdx/libgdx/wiki/Hiero)\n- `filename` (String)\n  - filename of both font file and font atlas. If omited, font face name is used. **Required** if font is provided as a Buffer.\n- `charset` (String|Array)\n  - the characters to include in the bitmap font. Defaults to all ASCII printable characters.\n- `fontSize` (Number)\n  - the font size at which to generate the distance field. Defaults to `42`\n- `textureSize` (Array[2])\n  - the dimensions of an output texture sheet, normally power-of-2 for GPU usage. Both dimensions default to `[512, 512]`\n- `texturePadding` (Number)\n  - pixels between each glyph in the texture. Defaults to `2`\n- `border` (Number)\n  - space between glyphs textures & edge. Defaults to `0`\n- `fieldType` (String)\n  - what kind of distance field to generate. Defaults to `msdf`. Must be one of:\n    - `msdf` Multi-channel signed distance field\n    - `sdf` Monochrome signed distance field\n    - `psdf` monochrome signed pseudo-distance field\n- `distanceRange` (Number)\n  - the width of the range around the shape between the minimum and maximum representable signed distance in pixels, defaults to `3`\n- `roundDecimal` (Number)\n  - rounded digits of the output font metics. For `xml` output, `roundDecimal: 0` recommended.\n- `vector` (Boolean)\n  - output a SVG Vector file for debugging. Defauts to `false`\n- `smart-size` (Boolean)\n  - shrink atlas to the smallest possible square. Default: `false`\n- `pot` (Boolean)\n  - output atlas size shall be power of 2. Default: `false`\n- `square` (Boolean)\n  - output atlas size shall be square. Default: `false`\n- `rot` (Boolean)\n  - allow 90-degree rotation while packing. Default: `false`\n- `rtl` (Boolean)\n  - use RTL(Arabic/Persian) charators fix. Default: `false`\n\nThe `callback` is called with the arguments `(error, textures, font)`\n\n- `error` on success will be null/undefined\n- `textures` an array of js objects of texture spritesheet.\n  - `textures[index].filename` Spritesheet filename\n  - `textures[index].texture` Image Buffers, containing the PNG data of one texture sheet\n- `font` an object containing the BMFont data, to be used to render the font\n  - `font.filename` font filename\n  - `font.data` stringified xml\\json data to be written to disk\n\nSince `opt` is optional, you can specify `callback` as the second argument.\n\n## License\n\nMIT, see [LICENSE.md](http://github.com/Jam3/xhr-request/blob/master/LICENSE.md) for details.\n","readmeFilename":"README.md","_rev":"1-c86554f4d4f68b02601ee30fc13b8ee3"}