Giter Site home page Giter Site logo

soimy / msdf-bmfont-xml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from experience-monks/msdf-bmfont

313.0 313.0 46.0 13.19 MB

Generate BMFont texture and spec XML using msdfgen

Home Page: https://soimy.github.io/msdf-bmfont-xml/

License: MIT License

JavaScript 97.74% CSS 0.78% HTML 1.48%

msdf-bmfont-xml's People

Contributors

ankushsha avatar arilotter avatar boulabiar avatar bunnybones1 avatar damienmortini avatar dependabot[bot] avatar donmccurdy avatar johh avatar mattdesl avatar musculman avatar newbloodmage avatar philanatidae avatar samskivert avatar soimy avatar tkwiatek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msdf-bmfont-xml's Issues

Doesn't work with npm run script

Hi! Thanks again, for this super tool!
It works perfect from cli, but when I try to run npm run font, for example it stucks on zero and do nothing here is an error:

npm run script:
font: "msdf-bmfont.cmd --reuse -i .\\fonts\\charset.roboto.txt -m 512,512 -f json -o .\\fonts\\Roboto-Regular.png -s 32 -r 8 -p 1 -t msdf .\\fonts\\Roboto-Regular.ttf"
Error:
image

It works fine from cli, but not from npm. By the way source folder placed in D:\My Projects\....

Cheers!

Recent changes regarding fontBuffer does not seem to work if fontPath is a string

There is some confusion regarding 2.5.3 and the latest changes done here regarding how fontFace is set: 6b659b4

Setting fontFace to filename (which can be an atlas_path string) if it exists, over path.basename(fontPath, path.extname(fontPath)); results in fontFace now being the full path if filename is a path.

Either let extracted filename take precedence:
const fontface = path.basename(fontPath, path.extname(fontPath)) || filename;

Or set fontFace afterwards (not sure if option X and Y is one and the same in all cases, depending on if fontPath is a Buffer or not).

Option X:

let fontface = filename || path.basename(fontPath, path.extname(fontPath));
if(!filename) {
  filename = fontface;
  console.log(`Use font-face as filename : ${filename}`);
} else {
  if (opt.filename) fontDir = path.dirname(opt.filename);
  filename = opt.filename = fontface = path.basename(filename, path.extname(filename));
}

Option Y:

let fontface = filename || path.basename(fontPath, path.extname(fontPath));
if(!filename) {
  filename = fontface;
  console.log(`Use font-face as filename : ${filename}`);
} else {
  if (opt.filename) fontDir = path.dirname(opt.filename);
  fontface = path.basename(fontPath, path.extname(fontPath));
  filename = opt.filename = fontface = path.basename(filename, path.extname(filename));
}

Error making atlas out of multiple fonts again

I am re-opening my previous issue, which still persists in version 2.5.4 on a Windows 10 administrator command prompt.

C:\>msdf-bmfont --reuse -o Atlas.png font1.ttf

Using following settings
========================================
version         : msdf-bmfont-xml v2.5.4
outputType      : xml
filename        : Atlas.png
fontSize        : 42
charsetFile     : Unspecified, fallback to ASC-II
textureSize     : 2048,2048
texturePadding  : 1
border          : 0
distanceRange   : 4
fieldType       : msdf
roundDecimal    : 0
vector          : false
reuse           : true
smartSize       : false
pot             : false
square          : false
rot             : false
rtl             : false
fontFile        : font1.ttf
========================================
No valid charset file loaded, fallback to ASC-II
Warning: no bitmap for character ' ' (32), adding to font as empty

Generation complete!

wrote font file        :  font1.fnt
wrote cfg file         :  Atlas.cfg
wrote spritesheet[ 0 ] :  Atlas.png

C:\>msdf-bmfont -u Atlas.cfg font2.ttf

Using following settings
========================================
version         : msdf-bmfont-xml v2.5.4
outputType      : xml
filename        : font2
fontSize        : 42
charsetFile     : Defined in [Atlas.cfg]
textureSize     : 2048,2048
texturePadding  : 1
border          : 0
distanceRange   : 4
fieldType       : msdf
roundDecimal    : 0
vector          : Defined in [Atlas.cfg]
reuse           : Atlas.cfg
smartSize       : Defined in [Atlas.cfg]
pot             : Defined in [Atlas.cfg]
square          : Defined in [Atlas.cfg]
rot             : Defined in [Atlas.cfg]
rtl             : Defined in [Atlas.cfg]
fontFile        : font2.ttf
========================================
File:  Atlas.cfg  not valid! Aborting...

I also tried specifying the full path for the like this, msdf-bmfont --reuse C:\Atlas.cfg font2.ttf
but the result was the same.

Packing setting save & re-use needed.

Most of the time, packed atlas will have much spare space left. It's necessary and possible to reuse previous Atlas and settings to add a new font to it.

Update the docs reference for textureWidth/textureHeight

When using in nodeJS, options.textureWidth/options.textureHeight doesn't work, looking at index.js seems the actual value is options.textureSize...
Maybe update index.js to have granular access to width/height, or README to reflect the correct prop name.

Update:
just realized .textureSize expected an array of [width,height], please update the README.

Run from electron

Good evening!

I have no problems using this package from node, but I wonder if there a good way to make this run from electron?

The following error is raised when I attempt to do so:
Uncaught Error: A dynamic link library (DLL) initialization routine failed.

Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\D:\Workspace\GitHub\_Scarlett\scarlett-editor\node_modules\canvas-prebuilt\canvas\build\Release\canvas.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:173:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:173:20)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (D:\Workspace\GitHub\_Scarlett\scarlett-editor\node_modules\canvas-prebuilt\canvas\lib\bindings.js:3:18)
    at Object.<anonymous> (D:\Workspace\GitHub\_Scarlett\scarlett-editor\node_modules\canvas-prebuilt\canvas\lib\bindings.js:5:3)

I tried to run electron-rebuild on it, but it still happens.
I wonder if I would need a specific build from canvas-prebuilt.
Any ideas?

Metrics fixes

Hey there,

I think it might be good to have a very robust test case for metrics that covers this module and also mdsf-bmfont. It seems like msdf-bmfont had some issues with alignment (Experience-Monks#11) which means all fonts exported with it may be wrong (and perhaps also msdf-bmfont-xml, since it seemed like I was getting similar alignments there).

Keep up the awesome work in this module, by the way! 😄

Add information about font distance field settings to XML file

I know that you recently added the type field to the XML file — thanks again for that!

However, now that I started implementation on this feature in Starling, I realised that I actually need more information — especially the "distance range".

So we could either add another property to the info element, like this:

<font>
    <info face="Arial" type="msdf" dfrange="4" .../>
    <!-- ... -->
</font>

or add another (optional) XML element altogether, e.g. like this:

<font>
    <info face="Arial" .../>
    <common lineHeight="46" .../>
    <distanceField distanceRange="4" fieldType="msdf" />
    <!-- ... -->
</font>

Perhaps the second approach would be cleaner, since it groups all distance field information together. You could also add more of your tool's settings, if it makes sense. What do you say to this?

With that information, I could not only switch to the DistanceFieldStyle automatically on text fields (if appropriate), but also apply the correct value for smoothing.

reuse field is required in case of using opt

Example:

const opt = {
        fieldType: 'sdf',
        reuse: false /// <<<< Without this flag you get error
    };

    generateBMFont(fontPath, opt, (error, textures, font) {
    ...
    }

Error:

path.js:28
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:28:11)
    at Object.dirname (path.js:1345:5)
    at generateBMFont (/.../node_modules/msdf-bmfont-xml/index.js:63:14)
   ...

SVG Import?

I have a bunch of icons in SVG i'd like to be part of the atlas. Is there an easy way to be able to append a folder of them during generation?

Missing characters in export png

in last issue you said that I must use a font with a lot of standard ASC-II characters
so I use this font :
https://www.dropbox.com/s/1fuigy78xi2jtx5/iransans.fnt?dl=0

and set charset.txt to these text:
ببب ب
تتت ت
ضضض ض
صصص ص
ثثث ث
ققق ق
ففف ف
غغغ غ
ععع ع
ههه ه
خخخ خ
ححح ح
ججج ج
چچچ چ
ششش ش
سسس س
ییی ئ ی ي
ببب ب
للل ل
اآ
ننن ن
ممم م
ککک ک
گگگ گ
ظظظ ظ
ططط ط
زرژ
و
ذد
پپپ پ
َُِّ
":><؟{}|+_()&*!@#$%×÷÷`|;'[].,/\،-=
12345567890

But my export png is still a problem :(
iransans 0

JSON error

Thanks for this! Has been a lifesaver.

There is a problem generating the JSON data, some chars are not strings but integers. XML always exports correctly. When creating JSON for OpenSans-Regular.ttf I get a chars like:

{"id":109,"index":80,"char":"m","width":36,"height":27,"xoffset":2,"yoffset":11,"xadvance":39,"chnl":15,"x":138,"y":0,"page":0},{"id":54,"index":25,"char":6,"width":24,"height":35,"xoffset":0,"yoffset":4,"xadvance":24,"chnl":15,"x":141,"y":115,"page":0}

Where the "m" is fine but the next character is 6 instead of "6".

This creates some headache with JSON decoders which are very type conscious, like the swift JSONDecoder.

Update: Only happens with characters 0-9. Looks like a failing type check.

Thanks

canvas-prebuilt incompatible with current node.js

internal/modules/cjs/loader.js:752
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: The module '/usr/local/lib/node_modules/msdf-bmfont-xml/node_modules/canvas-prebuilt/canvas/build/Release/canvas.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 67. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).
at Object.Module._extensions..node (internal/modules/cjs/loader.js:752:18)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:659:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/usr/local/lib/node_modules/msdf-bmfont-xml/node_modules/canvas-prebuilt/canvas/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
at Module.load (internal/modules/cjs/loader.js:620:32)

Error making atlas out of multiple fonts

I've been trying to make a single atlas out of multiple font files, but I always get a ".cfg not valid" error. What am I doing wrong? This is from an administrator Command Prompt in Windows 10 with Node.js version 12.10.0. I also tried it on a different Windows 10 machine with Node.js LTS version 10.16.3 and the result was the same.

msdf-bmfont --reuse -o Atlas.png font1.ttf

Using following settings
========================================
version         : msdf-bmfont-xml v2.5.2
outputType      : xml
filename        : Atlas.png
fontSize        : 42
charsetFile     : Unspecified, fallback to ASC-II
textureSize     : 2048,2048
texturePadding  : 1
border          : 0
distanceRange   : 4
fieldType       : msdf
roundDecimal    : 0
vector          : false
reuse           : true
smartSize       : false
pot             : false
square          : false
rot             : false
rtl             : false
fontFile        : font1.ttf
========================================
No valid charset file loaded, fallback to ASC-II
Warning: no bitmap for character ' ' (32), adding to font as empty

Generation complete!

wrote cfg file         :  Atlas.cfg
wrote spritesheet[ 0 ] :  Atlas.png
wrote font file        :  font1.fnt

msdf-bmfont --reuse Atlas.cfg font2.ttf

Using following settings
========================================
version         : msdf-bmfont-xml v2.5.2
outputType      : xml
filename        : font2
fontSize        : 42
charsetFile     : Unspecified, fallback to ASC-II
textureSize     : 2048,2048
texturePadding  : 1
border          : 0
distanceRange   : 4
fieldType       : msdf
roundDecimal    : 0
vector          : false
reuse           : Atlas.cfg
smartSize       : false
pot             : false
square          : false
rot             : false
rtl             : false
fontFile        : font2.ttf
========================================
File:  Atlas.cfg  not valid! Aborting...

Here is the Atlas.cfg:

{
	"opt": {
		"version": "msdf-bmfont-xml v2.5.2",
		"outputType": "xml",
		"filename": "Atlas",
		"fontSize": 42,
		"textureSize": [
			2048,
			2048
		],
		"texturePadding": 1,
		"border": 0,
		"distanceRange": 4,
		"fieldType": "msdf",
		"roundDecimal": 0,
		"vector": false,
		"smartSize": false,
		"pot": false,
		"square": false,
		"rot": false,
		"rtl": false,
		"fontFile": "font1.ttf",
		"fontSpacing": [
			0,
			0
		],
		"fontPadding": [
			0,
			0,
			0,
			0
		],
		"textureWidth": 2048,
		"textureHeight": 2048,
		"tolerance": 0,
		"charset": [
			" ",
			"!",
			"\"",
			"#",
			"$",
			"%",
			"&",
			"'",
			"(",
			")",
			"*",
			"+",
			",",
			"-",
			".",
			"/",
			"0",
			"1",
			"2",
			"3",
			"4",
			"5",
			"6",
			"7",
			"8",
			"9",
			":",
			";",
			"<",
			"=",
			">",
			"?",
			"@",
			"A",
			"B",
			"C",
			"D",
			"E",
			"F",
			"G",
			"H",
			"I",
			"J",
			"K",
			"L",
			"M",
			"N",
			"O",
			"P",
			"Q",
			"R",
			"S",
			"T",
			"U",
			"V",
			"W",
			"X",
			"Y",
			"Z",
			"[",
			"\\",
			"]",
			"^",
			"_",
			"`",
			"a",
			"b",
			"c",
			"d",
			"e",
			"f",
			"g",
			"h",
			"i",
			"j",
			"k",
			"l",
			"m",
			"n",
			"o",
			"p",
			"q",
			"r",
			"s",
			"t",
			"u",
			"v",
			"w",
			"x",
			"y",
			"z",
			"{",
			"|",
			"}",
			"~"
		]
	},
	"pages": [
		"Atlas.png"
	],
	"packer": {
		"bins": [
			{
				"width": 2048,
				"height": 2048,
				"maxWidth": 2048,
				"maxHeight": 2048,
				"freeRects": [
					{
						"x": 28,
						"y": 36,
						"width": 31,
						"height": 9
					},
					{
						"x": 40,
						"y": 116,
						"width": 29,
						"height": 4
					},
					{
						"x": 59,
						"y": 72,
						"width": 18,
						"height": 8
					},
					{
						"x": 22,
						"y": 260,
						"width": 18,
						"height": 10
					},
					{
						"x": 69,
						"y": 152,
						"width": 15,
						"height": 4
					},
					{
						"x": 77,
						"y": 108,
						"width": 19,
						"height": 8
					},
					{
						"x": 26,
						"y": 331,
						"width": 9,
						"height": 1
					},
					{
						"x": 35,
						"y": 366,
						"width": 4,
						"height": 2
					},
					{
						"x": 84,
						"y": 188,
						"width": 10,
						"height": 4
					},
					{
						"x": 27,
						"y": 439,
						"width": 18,
						"height": 1
					},
					{
						"x": 39,
						"y": 401,
						"width": 19,
						"height": 3
					},
					{
						"x": 58,
						"y": 436,
						"width": 1991,
						"height": 3
					},
					{
						"x": 78,
						"y": 436,
						"width": 1971,
						"height": 1613
					},
					{
						"x": 87,
						"y": 401,
						"width": 1962,
						"height": 1648
					},
					{
						"x": 94,
						"y": 223,
						"width": 11,
						"height": 5
					},
					{
						"x": 96,
						"y": 144,
						"width": 16,
						"height": 8
					},
					{
						"x": 91,
						"y": 359,
						"width": 1958,
						"height": 7
					},
					{
						"x": 104,
						"y": 359,
						"width": 1945,
						"height": 1690
					},
					{
						"x": 126,
						"y": 333,
						"width": 1923,
						"height": 1716
					},
					{
						"x": 105,
						"y": 258,
						"width": 16,
						"height": 5
					},
					{
						"x": 121,
						"y": 293,
						"width": 1928,
						"height": 5
					},
					{
						"x": 144,
						"y": 292,
						"width": 1905,
						"height": 1757
					},
					{
						"x": 129,
						"y": 292,
						"width": 1920,
						"height": 6
					},
					{
						"x": 72,
						"y": 295,
						"width": 19,
						"height": 1
					},
					{
						"x": 84,
						"y": 263,
						"width": 7,
						"height": 33
					},
					{
						"x": 61,
						"y": 255,
						"width": 11,
						"height": 5
					},
					{
						"x": 30,
						"y": 219,
						"width": 31,
						"height": 6
					},
					{
						"x": 55,
						"y": 192,
						"width": 6,
						"height": 33
					},
					{
						"x": 147,
						"y": 250,
						"width": 1902,
						"height": 1799
					},
					{
						"x": 136,
						"y": 250,
						"width": 1913,
						"height": 8
					},
					{
						"x": 128,
						"y": 143,
						"width": 19,
						"height": 1
					},
					{
						"x": 132,
						"y": 107,
						"width": 27,
						"height": 1
					},
					{
						"x": 144,
						"y": 71,
						"width": 17,
						"height": 1
					},
					{
						"x": 161,
						"y": 98,
						"width": 1888,
						"height": 9
					},
					{
						"x": 112,
						"y": 187,
						"width": 29,
						"height": 1
					},
					{
						"x": 138,
						"y": 179,
						"width": 3,
						"height": 9
					},
					{
						"x": 0,
						"y": 641,
						"width": 2049,
						"height": 1408
					},
					{
						"x": 14,
						"y": 606,
						"width": 2035,
						"height": 9
					},
					{
						"x": 26,
						"y": 606,
						"width": 2023,
						"height": 1443
					},
					{
						"x": 40,
						"y": 571,
						"width": 2009,
						"height": 1478
					},
					{
						"x": 28,
						"y": 571,
						"width": 2021,
						"height": 9
					},
					{
						"x": 161,
						"y": 218,
						"width": 1888,
						"height": 1831
					},
					{
						"x": 141,
						"y": 218,
						"width": 1908,
						"height": 5
					},
					{
						"x": 147,
						"y": 169,
						"width": 18,
						"height": 10
					},
					{
						"x": 165,
						"y": 193,
						"width": 1884,
						"height": 13
					},
					{
						"x": 167,
						"y": 193,
						"width": 1882,
						"height": 1856
					},
					{
						"x": 174,
						"y": 158,
						"width": 1875,
						"height": 11
					},
					{
						"x": 189,
						"y": 158,
						"width": 1860,
						"height": 1891
					},
					{
						"x": 50,
						"y": 525,
						"width": 1999,
						"height": 1524
					},
					{
						"x": 45,
						"y": 474,
						"width": 11,
						"height": 1
					},
					{
						"x": 164,
						"y": 61,
						"width": 21,
						"height": 10
					},
					{
						"x": 196,
						"y": 82,
						"width": 1853,
						"height": 1967
					},
					{
						"x": 185,
						"y": 82,
						"width": 1864,
						"height": 52
					},
					{
						"x": 184,
						"y": 26,
						"width": 7,
						"height": 9
					},
					{
						"x": 209,
						"y": 47,
						"width": 1840,
						"height": 2002
					},
					{
						"x": 191,
						"y": 47,
						"width": 1858,
						"height": 14
					},
					{
						"x": 34,
						"y": 543,
						"width": 2015,
						"height": 2
					},
					{
						"x": 202,
						"y": 18,
						"width": 1847,
						"height": 8
					},
					{
						"x": 212,
						"y": 17,
						"width": 1837,
						"height": 2032
					},
					{
						"x": 223,
						"y": 0,
						"width": 1826,
						"height": 2049
					},
					{
						"x": 211,
						"y": 17,
						"width": 1838,
						"height": 9
					},
					{
						"x": 58,
						"y": 510,
						"width": 1991,
						"height": 1539
					},
					{
						"x": 70,
						"y": 498,
						"width": 1979,
						"height": 1551
					},
					{
						"x": 17,
						"y": 131,
						"width": 13,
						"height": 4
					},
					{
						"x": 28,
						"y": 120,
						"width": 2,
						"height": 15
					},
					{
						"x": 159,
						"y": 35,
						"width": 5,
						"height": 1
					}
				],
				"rects": [],
				"options": {
					"smart": false,
					"pot": false,
					"square": false,
					"allowRotation": false,
					"tag": false,
					"border": 0
				}
			}
		]
	}
}

Arabic letter wrong glyph

Hi, @soimy ! I have an issue, I cant understand. Could you help, please.
Letter ڵ
looks like
image

I use NotoSansArabic-Regular from google fonts:
msdf-bmfont.cmd --reuse -i .\charset.txt -m 1024,1024 -f json -o NotoSansArabic-Regular.ttf.png -s 42 -r 14 -p 1 -t msdf --rtl NotoSansArabic-Regular.ttf

charset:
ڳڵڿ

Cheers!

Linux bin execution error

When calling your package from a JS script, I get the following error on linux (Ubuntu 16.04.6):

Error: Command failed: /mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux msdf -format text -stdout -size 11 16 -translate 2 26 -pxrange 8 -defineshape "{2.4, -13.664; 1.92, -22.048; 5.088, -22.048; 4.608, -13.664; 2.4, -13.664; }"
/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux: 9: /mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/bin/linux/msdfgen.linux: Syntax error: ")" unexpected

(node:61) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'slice' of undefined
    at MaxRectsPacker.sort (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/maxrects-packer/src/maxrects_packer.ts:125:22)
    at MaxRectsPacker.addArray (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/maxrects-packer/src/maxrects_packer.ts:70:14)
    at mapLimit (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/index.js:174:12)
    at f (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/map-limit/node_modules/once/once.js:17:25)
    at abort (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/map-limit/index.js:38:12)
    at /mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/map-limit/index.js:47:23
    at generateImage (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/index.js:166:23)
    at exec (/mnt/c/Users/ext_valencia.and/Dev/harp-font-resources/node_modules/msdf-bmfont-xml/index.js:329:21)
    at ChildProcess.exithandler (child_process.js:296:5)
    at ChildProcess.emit (events.js:182:13)

Any idea of why this might be happening? Only happens locally, and runs fine on a xenial docker image.

HELP with SVG

Not sure what I am doing wrong here.

-t, --field-type msdf(default) | sdf | psdf | svg (default: "msdf")

when I run
msdf-bmfont -t svg Downloads/RobotoMono-Bold.ttf

Using following settings
`========================================

  • version : msdf-bmfont-xml v2.5.2
  • outputType : xml
  • filename : Downloads/RobotoMono-Bold
  • fontSize : 42
  • charsetFile : Unspecified, fallback to ASC-II
  • textureSize : 2048,2048
  • texturePadding : 1
  • border : 0
  • distanceRange : 4
  • fieldType : svg
  • roundDecimal : 0
  • vector : false
  • reuse : false
  • smartSize : false
  • pot : false
  • square : false
  • rot : false
  • rtl : false
  • fontFile : Downloads/RobotoMono-Bold.ttf

`

Can you please assist here?

Thanks

Dependency 'handlebars' missing

After installing the tool, any attempt to run it produced the following error:

module.js:491
    throw err;
    ^

Error: Cannot find module 'handlebars'
    at Function.Module._resolveFilename (module.js:489:15)
    at Function.Module._load (module.js:439:25)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/msdf-bmfont-xml/cli.js:7:20)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)

It was fixed by installing handlebars manually via npm install handlebars. But I guess you can include that in the list of dependencies, right?

Can't generate a sheet with Japanese symbols

Hi! I've tried to add few Japanese symbols into charset string (こんにちは) and found that these symbols are not presented in an atlas. I've tried with several fonts without success. Are there any reasons behind this? Can this be easily fixed in some way? May be I have to try with any concrete fonts?
Thanks for answer!

Missing characters in export png

Hi
I have a persian font that you can download it from this link:
https://www.dropbox.com/s/lvlv8yulgjn3svh/B%20Koodak%20Bold.TTF?dl=0

I want to change this font to bitmapFont so I write this code:
msdf-bmfont -o koodak.png --charset-file charset.txt --texture-size 1024,1024 --smart-size koodak.ttf

also i set charset.txt to these characters:
ببب ب
تتت ت
ضضض ض
صصص ص
ثثث ث
ققق ق
ففف ف
غغغ غ
ععع ع
ههه ه
خخخ خ
ححح ح
ججج ج
چچچ چ
ششش ش
سسس س
ییی ئ ی ي
ببب ب
للل ل
اآ
ننن ن
ممم م
ککک ک
گگگ گ
ظظظ ظ
ططط ط
زرژ
و
ذد
پپپ پ
َُِّ
":><؟{}|+_()&*!@#$%×÷÷`|;'[].,/\،-=
12345567890

all set is done , but when i see the export png it show me a few characters not all characters that i set in charset.txt, why?

nazanin 0

Feature request: allow change char offsets

Hello, soimy!
In first let me express my gratitude for your work!

Several otf/ttf fonts output incorrect char offsets, for example attached font have huge yoffset, all characters are shifted down. Usually, I run script which fix offsetY values on all char.

This is not a bug of your utility, this is font's peculiarity.

It will be cool if msdf-bmfont-xml can change offsetX / offsetY by custom value.

Suggestion: changing sizing-defaults of command-line tool

Hey Shen,

I'd like to suggest two small changes of the default values of the command-line tool. I guess I'm a little lazy, so I like to avoid having to type a lot of arguments when it shouldn't be necessary. 😉

IMHO, most developers will just want to get the single (!) smallest texture that's able to pick up the glyphs. Furthermore, I don't know of any (at least somewhat modern) graphics hardware that can't load textures with at least 2048x2048 pixels. So I'd suggest changing two default settings from their current setting:

textureSize     : 256,256
smartSize       : false

To:

textureSize     : 2048,2048
smartSize       : true

Because then, a simple call like this:

$> msdf-bmfont Arial.ttf

Would already produce the output most users will want to have — one font file, one texture file. And if that users is limited to POT-textures, just a single additional argument (--pot) will solve his problem. My guess is that 90% of the use-cases will work out of the box with these defaults.

Thanks for considering this! 😄

Cheers,
Daniel

Text appears transparent in colored tectanle

I've been trying to create my own msdf fonts, based on Roboto which I fetched from Google Fonts. Using this tool and then loading it in Three.JS with https://github.com/Jam3/three-bmfont-text loads transparent text in a colored rectangle. It works fine if I load the pre generated Roboto from here: https://github.com/Jam3/three-bmfont-text/tree/master/test/fnt

Error:
broken_font

I've tried both on Ubuntu and Windows and with multiple Roboto ttfs, and other fonts.

Vulnerability issue

Running npm audit or yarn audit shows a few vulnerabilities on this package:

yarn audit v1.12.3
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ msdf-bmfont-xml                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ msdf-bmfont-xml > canvas-prebuilt > node-pre-gyp > hawk >    │
│               │ boom > hoek                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ msdf-bmfont-xml                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ msdf-bmfont-xml > canvas-prebuilt > node-pre-gyp > hawk >    │
│               │ cryptiles > boom > hoek                                      │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ msdf-bmfont-xml                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ msdf-bmfont-xml > canvas-prebuilt > node-pre-gyp > hawk >    │
│               │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ msdf-bmfont-xml                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ msdf-bmfont-xml > canvas-prebuilt > node-pre-gyp > hawk >    │
│               │ sntp > hoek                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ msdf-bmfont-xml                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ msdf-bmfont-xml > canvas-prebuilt > node-pre-gyp > request > │
│               │ hawk > boom > hoek                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ msdf-bmfont-xml                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ msdf-bmfont-xml > canvas-prebuilt > node-pre-gyp > request > │
│               │ hawk > cryptiles > boom > hoek                               │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ msdf-bmfont-xml                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ msdf-bmfont-xml > canvas-prebuilt > node-pre-gyp > request > │
│               │ hawk > hoek                                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ hoek                                                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ > 4.2.0 < 5.0.0 || >= 5.0.3                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ msdf-bmfont-xml                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ msdf-bmfont-xml > canvas-prebuilt > node-pre-gyp > request > │
│               │ hawk > sntp > hoek                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/566                       │
└───────────────┴──────────────────────────────────────────────────────────────┘
```

Is this already reported/known and is this perhaps already reported?
Thanks

Missing padding info

Hey there!

I've noticed that font.info.padding is always [0, 0, 0, 0].
Since some padding info is calculated here shouldn't that info be made available in font.info.padding? It'd come in handy when aligning things or calculating metrics.

I'm happy to submit a PR.

Floating point exception in 2.3.6

After updating from 2.3.5 to 2.3.6 I get the error message: zsh: floating point exception when running the command:
msdf-bmfont --reuse -f json -o atlas.png -m 512,512 -s 64 -r 2 font.ttf

It works as expected if I don't specify texture size. Is there something I have missed out in the new version?

HYHeiLiZhiTiJ.ttf to MSDF

In the test case, I changed DIN_CB.ttf to HYHeiLiZhiTiJ.ttf can not generate all fonts, especially the Chinese part, what should I do to convert the whole HYHeiLiZhiTiJ.ttf to msdf, including Chinese?

Crash when using npm run render

Windows7, node v12.4.0 over here:

  • cloned the repo
  • npm install
  • npm install -g devtool
  • npm run render

And boom, crash:

showcase

Could you advice? :)

CLI doesn't work

I get this error:

$ msdf-bmfont
env: node\r: No such file or directory

Binaries not executable in 2.3.2

The binaries in the 2.3.2 release don't seem to be executable:

screen shot 2018-02-09 at 4 26 02 pm

A manual chmod after installation fixes the issue. I don't see anything in the commit history to explain that. 😕

I am using macOS here.

Missing characters in fnt and png

I tried running my ttf with a custom charset that includes characters for multiple languages, but when I view the output fnt file, it only has 97 of the 170 characters that I'm expecting (from my charset).
My charset is: https://gist.github.com/soccerob/c509e967017c1acdf06c2aca5ce4344b

!  "#$%&'()*+,-./0123456789:;?@abcdefghijklmnopqrstuvwxyz[]^_`abcdefghijklmnopqrstuvwxyz{|}~¡«»¿ÀÁÂÄÅÆÇÈÉÊËÌÍÎÏÑÒÓÔÖØÙÚÛÜßàáâäåæçèéêëìíîïñòóôöøùúûüÿŒœŸ–—’“”„€\‘<=>°·•ãúõ

Texture size not working

Hi, first of all thanks for this great tool!

I try to run the following command : msdf-bmfont --reuse -o fonts/arial.png -m 512,512 -s 15 -r 3 -p 1 -t msdf fonts/arial.ttf -f json
and get the following error.

Can someone show me how to create a texture size 512x512?
If I remove the -m 512,512 it uses the default settings and generate 2048x2048 texture image

Using following settings

version : msdf-bmfont-xml v2.5.4
outputType : json
filename : fonts/ltmono.png
fontSize : 15
charsetFile : Unspecified, fallback to ASC-II
textureSize : 512 512
texturePadding : 1
border : 0
distanceRange : 3
fieldType : msdf
roundDecimal : 0
vector : false
reuse : true
smartSize : false
pot : false
square : false
rot : false
rtl : false
fontFile : fonts\ltmono.ttf

No valid charset file loaded, fallback to ASC-II
assert.js:391
throw err;
^

AssertionError [ERR_ASSERTION]: textureSize format shall be: width,height
at generateBMFont (C:\Users\Cru\AppData\Roaming\npm\node_modules\msdf-bmfont-xml\index.js:62:10)
at ReadFileContext.callback (C:\Users\Cru\AppData\Roaming\npm\node_modules\msdf-bmfont-xml\cli.js:101:3)
at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:282:13) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}

Font data may write before chars parsed

fontFile.data = utils.stringify(fontData, outputType);
may happens before
const asyncTextures = await Promise.all(textures);
So chars data may be empty.

It's happens for me when i try to reuse texture for another font. My solution is to move first line after second.

xadvance issue in Persian/Arabic (RTL)language

First thank u for correct miss characters in charset.txt for RTL languages
but as you see in this picture now we have a problem with xoffset like اییی or اششش or اططط
is there any way to set xoffset to correct this problem ?
xoffsetproblem

Generating font with large charset

When trying to generate font with large charset (700+ characters) I get following error:

UnhandledPromiseRejectionWarning: Error: Command failed: C:\Users\user\AppData\Roaming\npm\node_modules\msdf-bmfont-xml\bin\win32\msdfgen.exe msdf -format text -stdout -size 42 42 -translate 0 36 -pxrange 4 -defineshape "{7.77, -3.948; 7.77, -14.406; (7.056, -12.264); 6.006, -9.828; (4.956, -7.392); 3.654, -5.25; 3.654, -5.25; (3.192, -6.342); 2.814, -6.972; (2.436, -7.602); 1.764, -8.442; 1.764, -8.442; (3.738, -11.13); 5.187, -14.616; (6.636, -18.102); 7.728, -22.68; 7.728, -22.68; (6.258, -22.638); 5.04, -22.554; (3.822, -22.47); 2.94, -22.344; 2.94, -22.344; 2.94, -25.578; (3.78, -25.452); 5.04, -25.368; (6.3, -25.284); 7.77, -25.242; 7.77, -25.242; (7.77, -28.14); 7.707, -30.072; (7.644, -32.004); 7.434, -33.222; 7.434, -33.222; (8.4, -33.012); 9.261, -32.928; (10.122, -32.844); 10.584, -32.886; 10.584, -32.886; (11.298, -32.97); 11.403, -32.655; (11.508, -32.34); 10.836, -31.878; 10.836, -31.878; (10.542, -31.668); 10.5, -31.437; (10.458, -31.206); 10.458, -30.87; 10.458, -30.87; 10.458, -25.284; (11.298, -25.326); 12.033, -25.389; (12.768, -25.452); 13.482, -25.578; 13.482, -25.578; 13.482, -24.57; 14.532, -26.208; (14.952, -25.956); 15.351, -25.704; (15.75, -25.452); 16.128, -25.158; 16.128, -25.158; (16.464, -25.746); 16.8, -26.334; (17.136, -26.922); 17.472, -27.762; 17.472, -27.762; (17.766, -28.35); 17.976, -28.854; (18.186, -29.358); 18.375, -29.883; (18.564, -30.408); 18.732, -31.017; (18.9, -31.626); 19.11, -32.466; 19.11, -32.466; (19.95, -32.004); 20.685, -31.731; (21.42, -31.458); 22.134, -31.248; 22.134, -31.248; (23.31, -30.912); 22.26, -30.408; 22.26, -30.408; (21.924, -30.24); 21.651, -29.925; (21.378, -29.61); 21.042, -28.98; 21.042, -28.98; (20.16, -27.342); 19.53, -26.208; (18.9, -25.074); 18.102, -23.772; 18.102, -23.772; (18.522, -23.436); 18.942, -23.121; (19.362, -22.806); 19.782, -22.47; 19.782, -22.47; (21.63, -24.864); 22.176, -27.594; 22.176, -27.594; (22.89, -27.048); 23.436, -26.775; (23.982, -26.502); 24.528, -26.334; 24.528, -26.334; (25.368, -26.082); 24.57, -25.284; 24.57, -25.284; (24.444, -25.158); 24.255, -24.906; (24.066, -24.654); 23.562, -23.898; 23.562, -23.898; (22.764, -22.68); 21.567, -21.021; (20.37, -19.362); 18.648, -17.094; 18.648, -17.094; (19.404, -17.178); 20.265, -17.262; (21.126, -17.346); 22.176, -17.472; 22.176, -17.472; (21.966, -18.018); 21.735, -18.459; (21.504, -18.9); 21.294, -19.236; 21.294, -19.236; 23.478, -19.95; (24.192, -18.606); 24.78, -17.304; (25.368, -16.002); 25.914, -14.49; 25.914, -14.49; 23.646, -13.65; (23.562, -13.902); 23.394, -14.406; (23.226, -14.91); 23.016, -15.498; 23.016, -15.498; 17.934, -14.616; (17.346, -14.532); 16.8, -14.343; (16.254, -14.154); 15.918, -13.944; 15.918, -13.944; (15.582, -14.952); 15.267, -15.624; (14.952, -16.296); 14.532, -16.926; 14.532, -16.926; (14.868, -16.926); 15.204, -16.926; (15.54, -16.926); 15.876, -16.968; 15.876, -16.968; (16.59, -17.85); 17.115, -18.564; (17.64, -19.278); 18.27, -20.16; 18.27, -20.16; (16.842, -21.378); 15.729, -22.155; (14.616, -22.932); 13.482, -23.73; 13.482, -23.73; 13.482, -22.344; (12.894, -22.428); 12.138, -22.491; (11.382, -22.554); 10.458, -22.638; 10.458, -22.638; 10.458, -18.27; 12.222, -19.152; (13.062, -17.64); 13.692, -16.443; (14.322, -15.246); 14.994, -13.944; 14.994, -13.944; 12.432, -12.6; (12.222, -13.314); 11.697, -14.469; (11.172, -15.624); 10.458, -16.842; 10.458, -16.842; 10.458, -3.948; (10.458, -2.352); 10.521, -0.357; (10.584, 1.638); 10.752, 3.654; 10.752, 3.654; 7.35, 3.654; (7.56, 1.638); 7.665, -0.357; (7.77, -2.352); 7.77, -3.948; 7.77, -3.948; }{32.718, -11.928; 32.718, -11.928; (32.508, -12.558); 32.151, -13.23; (31.794, -13.902); 31.206, -14.616; 31.206, -14.616; 34.23, -15.582; (34.734, -14.742); 35.133, -14.049; (35.532, -13.356); 36.036, -12.39; 36.036, -12.39; 34.566, -11.97; (36.246, -12.012); 37.422, -12.096; (38.598, -12.18); 39.186, -12.264; 39.186, -12.264; 39.186, -9.156; (38.64, -9.24); 37.947, -9.282; (37.254, -9.324); 36.162, -9.366; (35.07, -9.408); 33.453, -9.408; (31.836, -9.408); 29.526, -9.408; 29.526, -9.408; (30.03, -7.308); 30.912, -5.292; 30.912, -5.292; (31.878, -6.258); 32.718, -7.224; (33.558, -8.19); 34.146, -9.24; 34.146, -9.24; (34.692, -8.862); 35.49, -8.442; (36.288, -8.022); 36.75, -7.812; 36.75, -7.812; (37.548, -7.476); 37.527, -7.119; (37.506, -6.762); 36.666, -6.72; 36.666, -6.72; (36.288, -6.678); 35.868, -6.426; (35.448, -6.174); 35.028, -5.796; 35.028, -5.796; (34.314, -5.082); 33.642, -4.431; (32.97, -3.78); 32.298, -3.15; 32.298, -3.15; (32.928, -2.31); 33.453, -1.785; (33.978, -1.26); 34.44, -0.882; 34.44, -0.882; (35.028, -0.42); 35.406, -0.252; (35.784, -0.084); 36.036, -0.378; (36.288, -0.672); 36.435, -1.512; (36.582, -2.352); 36.666, -3.864; 36.666, -3.864; (37.38, -3.276); 38.178, -2.919; (38.976, -2.562); 39.69, -2.478; 39.69, -2.478; (39.186, 0.084); 38.661, 1.512; (38.136, 2.94); 37.569, 3.528; (37.002, 4.116); 36.351, 4.011; (35.7, 3.906); 34.902, 3.318; 34.902, 3.318; (33.684, 2.436); 32.529, 1.365; (31.374, 0.294); 30.282, -1.218; 30.282, -1.218; (28.77, 0.168); 27.279, 1.344; (25.788, 2.52); 24.192, 3.444; 24.192, 3.444; (23.73, 2.646); 22.911, 1.869; (22.092, 1.092); 21.126, 0.672; 21.126, 0.672; (22.806, 0.462); 24.864, -0.672; (26.922, -1.806); 28.938, -3.444; 28.938, -3.444; (28.35, -4.662); 27.846, -6.237; (27.342, -7.812); 27.048, -9.408; 27.048, -9.408; 21.042, -9.408; (20.958, -8.232); 20.79, -7.14; 20.79, -7.14; (21.462, -6.804); 22.218, -6.405; (22.974, -6.006); 23.73, -5.586; (24.486, -5.166); 25.137, -4.788; (25.788, -4.41); 26.25, -4.116; 26.25, -4.116; 23.898, -1.596; (22.932, -2.52); 21.987, -3.276; (21.042, -4.032); 20.202, -4.62; 20.202, -4.62; (19.614, -2.478); 18.438, -0.378; (17.262, 1.722); 15.288, 3.696; 15.288, 3.696; (14.616, 3.192); 13.734, 2.688; (12.852, 2.184); 11.97, 1.764; 11.97, 1.764; (13.272, 1.092); 14.364, -0.063; (15.456, -1.218); 16.296, -2.709; (17.136, -4.2); 17.703, -5.922; (18.27, -7.644); 18.522, -9.408; 18.522, -9.408; (16.926, -9.366); 15.561, -9.303; (14.196, -9.24); 13.44, -9.156; 13.44, -9.156; 13.44, -12.264; (14.406, -12.138); 16.254, -12.012; (18.102, -11.886); 20.076, -11.886; 20.076, -11.886; 26.628, -11.886; (26.166, -15.036); 25.851, -18.123; (25.536, -21.21); 25.41, -24.486; 25.41, -24.486; (25.326, -26.586); 25.221, -28.014; (25.116, -29.442); 25.011, -30.45; (24.906, -31.458); 24.759, -32.193; (24.612, -32.928); 24.444, -33.642; 24.444, -33.642; (25.242, -33.432); 26.334, -33.264; (27.426, -33.096); 28.266, -33.054; 28.266, -33.054; (29.106, -33.012); 29.148, -32.676; (29.19, -32.34); 28.56, -31.878; 28.56, -31.878; (28.35, -31.71); 28.203, -31.584; (28.056, -31.458); 27.993, -31.269; (27.93, -31.08); 27.909, -30.807; (27.888, -30.534); 27.888, -30.114; 27.888, -30.114; (27.93, -28.896); 27.951, -27.447; (27.972, -25.998); 28.014, -24.78; 28.014, -24.78; 29.19, -26.334; (29.4, -26.166); 29.61, -26.019; (29.82, -25.872); 30.03, -25.704; 30.03, -25.704; (30.408, -26.292); 30.765, -26.964; (31.122, -27.636); 31.458, -28.476; 31.458, -28.476; (31.71, -29.106); 31.92, -29.61; (32.13, -30.114); 32.298, -30.639; (32.466, -31.164); 32.634, -31.752; (32.802, -32.34); 33.012, -33.18; 33.012, -33.18; (33.852, -32.718); 34.587, -32.445; (35.322, -32.172); 36.036, -31.962; 36.036, -31.962; (37.086, -31.668); 36.162, -31.122; 36.162, -31.122; (35.868, -30.912); 35.595, -30.618; (35.322, -30.324); 34.944, -29.694; 34.944, -29.694; (34.02, -28.056); 33.348, -26.901; (32.676, -25.746); 31.878, -24.318; 31.878, -24.318; (32.256, -24.024); 32.655, -23.709; (33.054, -23.394); 33.516, -22.974; 33.516, -22.974; (34.65, -24.654); 35.154, -25.788; (35.658, -26.922); 35.868, -27.93; 35.868, -27.93; (36.666, -27.426); 37.422, -27.048; (38.178, -26.67); 38.682, -26.502; 38.682, -26.502; (39.228, -26.334); 39.228, -26.019; (39.228, -25.704); 38.514, -25.578; 38.514, -25.578; (38.304, -25.536); 38.031, -25.284; (37.758, -25.032); 37.254, -24.234; 37.254, -24.234; (37.002, -23.814); 36.456, -23.058; (35.91, -22.302); 35.238, -21.42; (34.566, -20.538); 33.852, -19.614; (33.138, -18.69); 32.508, -17.934; 32.508, -17.934; (33.516, -17.934); 34.293, -17.976; (35.07, -18.018); 36.162, -18.102; 36.162, -18.102; (35.49, -19.404); 34.986, -20.076; 34.986, -20.076; 37.296, -21.42; (38.052, -20.076); 38.787, -18.732; (39.522, -17.388); 40.236, -16.002; 40.236, -16.002; 37.632, -14.742; (37.506, -15.078); 37.38, -15.414; (37.254, -15.75); 37.044, -16.128; 37.044, -16.128; 31.668, -15.582; (31.08, -15.498); 30.576, -15.393; (30.072, -15.288); 29.736, -15.078; 29.736, -15.078; (29.484, -16.548); 28.476, -17.892; 28.476, -17.892; (28.854, -17.892); 29.211, -17.913; (29.568, -17.934); 29.904, -17.934; 29.904, -17.934; (30.45, -18.606); 30.912, -19.215; (31.374, -19.824); 32.088, -20.874; 32.088, -20.874; (30.912, -21.966); 29.967, -22.743; (29.022, -23.52); 28.014, -24.234; 28.014, -24.234; (28.014, -20.958); 28.308, -17.829; (28.602, -14.7); 29.064, -11.886; 29.064, -11.886; (30.072, -11.886); 30.975, -11.886; (31.878, -11.886); 32.718, -11.928; }"
The command line is too long.

The font is STHeiti TC Medium. Hovewer, I tried the same charset with Simhei and it worked fine

cli padding option seems to have no effect

First, thanks for the great tool! Nice and easy to set up and it does almost exactly what I need.

I'm looking for an option to add a 1 px padding to each character. From the cli options, I expected the -p or --texture-padding option to handle this. However, I'm seeing no difference in the rendered texture.

The description seems to match what I'd expect for fontPadding, that is padding between each character in the texture, but the full name maps to texturePadding. When I inspected the output .json, ["info"]["padding"] is always [0, 0, 0, 0] regardless of the value I use. Additionally, this doesn't seem to pad the inside of the texture or each glyph. Looking through the generateBMFont method of index.js I see two options being loaded, and at least opt.texturePadding is passed to MaxRectsPacker.

Should I be specifying something else? Is there a way to repeat the last 1px of each character when rendering to the .png? Is the option exposed but not hooked up?

I'm running this with:

msdf-bmfont -o "FONT.png" -m 256,256 -s 32 -r 5 -p 1 -f json -t msdf "FONT.ttf"

Thanks again!

Add support for OpenType fonts

I just tried msdf-bmfont-xml with an OTF font (e.g. this one). When doing so, this line will cause an error to be thrown.

However, it seems that this is not necessary, because when I change the line to the following, it works just fine:

if (font.outlinesFormat !== 'truetype' && font.outlinesFormat !== 'cff') {
    // ...
}

I'm not sure if this is the case for all OpenType fonts, but it's worth a try, perhaps. Cheers! 😄

Misc Enhancement Suggestions

After using the command line tool for a while, I have to repeat I'm extremely grateful that you created it — hands-down the best way to create distance field bitmap fonts!!

I ran into a few minor things that caused me a little more work than would probably be necessary. This issue contains suggestions for small changes that seem to make sense for me. Perhaps one or more of them can be implemented in the future.

Enhancement ideas:

Enhance tool output

When the command line tool runs, it shows the following output:

Using following settings
========================================
version         : msdf-bmfont-xml v2.3.0
outputType      : xml
filename        : temp/fonts.png
fontSize        : undefined
charsetFile     : charset.txt
textureSize     : undefined
texturePadding  : undefined
distanceRange   : undefined
fieldType       : undefined
roundDecimal    : 0
vector          : undefined
reuse           : true
tolerance       : 0
smartSize       : true
pot             : undefined
square          : undefined
========================================

The string "undefined" is used whenever a setting was not assigned by the user.
It would be useful to show the actual value that is used in that case (i.e. the default value of that setting).

Allow manually naming config file

When the command line tool is run with the --reuse option and the specified file is not found, the process is aborted. Instead, it would be better if that file name would then be used as name of the config file that's created.

Omit .0

Oftentimes, there will be only one PNG file in the output. In that case, it would be useful if you omitted the .0 suffix. It makes it a little hard to use the tool in a script, for example, because you can only guess the output name.

Ignore 'new line' characters in charset file

It's useful to group characters into multiple lines in the charset files. However, this means that the newline character is added to the font XML file, which is not desired.

Fix typo in command line output

Replace "genrating" with "generating" ;)

Support fontBuffer as alternative to fontPath

I'm migrating https://msdf-bmfont.donmccurdy.com/ (which is basically a web GUI for creating MSDF fonts...) to a newer version of my web hosting service. The new platform version doesn't allow writing anything to disk — but on the bright side it's much cheaper to run!

At this point I've got everything working, except that this package requires fontPath as a path on disk. The opentype dependency has a opentype.parse(buffer) method that should be able to handle a Buffer object instead.

If I write up a PR adding fontBuffer support, would you be open to merging that? Proposed API:

generateBMFont(fontBuffer, opt, (error, textures, font) => {
  ...
});

Inconsistent results in linux vs macOS

I'm trying to make a little hosted service to create bmfont files, and am getting oddly different results when running the same thing locally (macOS) vs Docker (linux, but thanks to Docker magic, i'm not actually sure what linux distro this is...).

Guessing I'll need to dig into the linux version and see if there are open issues there, but wanted to file something here in case you have any ideas. This is the new v2.3.2, haven't tested anything earlier.

macOS linux
screen shot 2018-02-10 at 2 45 55 pm screen shot 2018-02-10 at 2 46 08 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.