Skip to content

Commit 33598b9

Browse files
committed
feat: new border option to control packing space to atlas edge
1 parent a1494ca commit 33598b9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cli.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ args
2020
.option('-i, --charset-file <charset>', 'user-specified charactors from text-file', fileExistValidate)
2121
.option('-m, --texture-size <w,h>', 'ouput texture atlas size (defaut: 2048,2048)', (v) => {return v.split(',')}, [2048, 2048])
2222
.option('-p, --texture-padding <n>', 'padding between glyphs (default: 1)', 1)
23+
.option('-b, --border <n>', 'space between glyphs textures & edge (default: 0)', 0)
2324
.option('-r, --distance-range <n>', 'distance range for SDF (default: 4)', 4)
2425
.option('-t, --field-type <type>', 'msdf(default) | sdf | psdf | svg', /^(msdf|sdf|psdf|svg)$/i, 'msdf')
2526
.option('-d, --round-decimal <digit>', 'rounded digits of the output font file. (Defaut: 0)', 0)

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function generateBMFont (fontPath, opt, callback) {
9292
const textureWidth = opt.textureWidth = utils.valueQueue([opt.textureSize || reuse.textureSize, [512, 512]])[0];
9393
const textureHeight = opt.textureHeight = utils.valueQueue([opt.textureSize || reuse.textureSize, [512, 512]])[1];
9494
const texturePadding = opt.texturePadding = utils.valueQueue([opt.texturePadding, reuse.texturePadding, 1]);
95+
const border = opt.border = utils.valueQueue([opt.border, reuse.border, 0]);
9596
const distanceRange = opt.distanceRange = utils.valueQueue([opt.distanceRange, reuse.distanceRange, 4]);
9697
const fieldType = opt.fieldType = utils.valueQueue([opt.fieldType, reuse.fieldType, 'msdf']);
9798
const roundDecimal = opt.roundDecimal = utils.valueQueue([opt.roundDecimal, reuse.roundDecimal]); // if no roudDecimal option, left null as-is
@@ -118,7 +119,9 @@ function generateBMFont (fontPath, opt, callback) {
118119
smart: smartSize,
119120
pot: pot,
120121
square: square,
121-
allowRotation: allowRotation
122+
allowRotation: allowRotation,
123+
tag: false,
124+
border: border
122125
});
123126
const chars = [];
124127

0 commit comments

Comments
 (0)