Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catchup with upstream #1

Open
wants to merge 78 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
c1b92aa
Merge remote-tracking branch 'origin/master' into develop
soimy Dec 25, 2017
ec8259c
Adapt the maxrects_packer v2
soimy Dec 26, 2017
f87d86c
Fixed bug: omit output filename lead to double path appended.
soimy Dec 29, 2017
6d6be95
Fix bugs:
soimy Dec 29, 2017
14d0130
Merge branch 'develop' of https://github.com/soimy/msdf-bmfont-xml in…
soimy Dec 29, 2017
27a165e
update npm
soimy Jan 3, 2018
ff71775
WIP: changing cli module
soimy Jan 4, 2018
e28f65c
Implemented cli default value, reuse can mannually specify filename. …
soimy Jan 5, 2018
2bde0d0
Fixed bug with manually assign cfg file
soimy Jan 6, 2018
6f9524d
Cleanup & update dependency
soimy Jan 6, 2018
690b171
Merge branch 'master' into develop
soimy Feb 14, 2018
0f9cfdc
repaire msdfgen win32 binary
soimy Feb 14, 2018
75f7d35
Update msdfgen executable permission
soimy Feb 14, 2018
308f0e5
Update linux binary with local shared libraries.
soimy Feb 14, 2018
f31fe00
Remove unnessecery shared library
soimy Feb 14, 2018
bbeabff
Add missing libstdc++ dependency for msdfgen linux binary
soimy Feb 15, 2018
eadecd7
Bump canvas-prebuilt version for libpng12.so.12 issue
soimy Feb 15, 2018
d14db9a
Change Default value for texture size & smart-size
soimy Jun 29, 2018
a61ffb3
replaced deprecated canvas-builtin with canvas (#29)
bunnybones1 Jan 28, 2019
6142b5b
Solves Issue#30 by updating dependencies (#31)
musculman Mar 14, 2019
30d8967
Update dependencies & fix vulnerabilityes
soimy Mar 14, 2019
4f8ab26
Fix #28 json Numeric charactor not parse correctly
soimy Mar 14, 2019
67cd028
Update README to correct textureSize param
soimy Mar 14, 2019
4b1ad9b
Merge branch 'develop'
soimy Mar 14, 2019
7fbcb77
Version 2.3.6 - Json numeric char parse fix & Dep. update
soimy Mar 14, 2019
fe70fd3
Update canvas 2.x api
soimy Mar 16, 2019
5e51760
Replace canvas with jimp
soimy Mar 17, 2019
3911e85
Clean up codes
soimy Mar 18, 2019
5b92447
Merge remote-tracking branch 'origin/canvas2jimp'
soimy Mar 18, 2019
e22589b
Version 2.4.0 - Replace Node-Canvas with Jimp
soimy Mar 18, 2019
fa5e9a9
Remove progress bar in warning message
soimy Mar 22, 2019
d251e03
force number type on texturePadding to avoid type error in MaxRectsPa…
damienmortini May 6, 2019
d3030e6
Cast string to number, solves #33 #35
soimy May 7, 2019
4929a54
Merge remote-tracking branch 'origin/develop'
soimy May 7, 2019
90a285a
Version 2.4.1 - Fix cli parameter type casting bug
soimy May 7, 2019
7f68279
Allow 90-degree rotation in packing
soimy May 9, 2019
16cc94d
Fix vulnerabilities
soimy May 9, 2019
f55d3ef
Cleanup codes
soimy May 9, 2019
c2f8ea8
Update comment & README
soimy May 9, 2019
f1e5b6c
Version 2.4.2 - New options: allowRotation
soimy May 9, 2019
bb525ec
Fix -rot in npm test
soimy May 11, 2019
24a72ab
README add npm monthly download badge
soimy May 13, 2019
5aef27e
Fix: #28 json string strict casting
soimy Jun 3, 2019
2d853e7
Version 2.4.3 - Fix: json string strict casting
soimy Jun 3, 2019
a1494ca
chore: npm -> yarn, add some dev toolchain
soimy Jun 19, 2019
33598b9
feat: new border option to control packing space to atlas edge
soimy Jun 19, 2019
9fd9aa9
chore(release): 2.5.0
soimy Jun 19, 2019
071b016
test: Fix run render by replacing abandoned devtools
soimy Jun 25, 2019
16759b3
docs: Update Readme to reflect new `border` option
soimy Jun 27, 2019
84732bf
fix: package script render changed to yarn
soimy Jul 2, 2019
5d95b32
fix: async jimp.read() should be fulfilled before continue packing
soimy Jul 11, 2019
007a6c5
Merge branch 'master' of https://github.com/soimy/msdf-bmfont-xml
soimy Jul 11, 2019
612da74
chore: back to npm
soimy Jul 11, 2019
e5c15ee
chore(release): 2.5.1
soimy Jul 11, 2019
230d0b3
fix: async texture generation skips fontData stringify
soimy Jul 12, 2019
ff3669c
chore(release): 2.5.2
soimy Jul 12, 2019
09b1171
output padding info by default (#43)
johh Jan 18, 2020
bbf8286
Bump handlebars from 4.1.2 to 4.3.0 (#45)
dependabot[bot] Jan 18, 2020
6b659b4
Support 'fontBuffer' parameter for in-memory generation. (#48)
donmccurdy Jan 18, 2020
12a60e3
refactor: Update arabic-persian-reshaper API & version
soimy Jan 26, 2020
7b1f2a7
chore(release): 2.5.3
soimy Jan 26, 2020
ae559fd
fix: omit path in font-face
soimy Feb 2, 2020
c37cc40
fix: CLI&document for SVG debug generation from `-t svg` to `-v`
soimy Feb 8, 2020
3b57562
fix: Re-use cfg settings not applied
soimy Feb 8, 2020
e05c94d
chore(release): 2.5.4
soimy Feb 8, 2020
23aace9
feat: Add version update-notifier
soimy Feb 8, 2020
5209f7c
Using stdin to transfer shapeDesc (#52)
newbloodmage Jun 22, 2020
b6c8f6b
Fix binary path not working when containing spaces (#59)
Philanatidae Feb 8, 2021
c193d38
Upgrade Jimp 0.16.1 (#63)
ankushSha May 6, 2021
17a79b9
chore(release): 2.6.0
soimy Jan 31, 2022
47cc4f9
Update Readme
soimy Feb 1, 2022
235bce6
Create node.js.yml
soimy Feb 15, 2022
34d8976
feat: add new output type: txt
soimy Jul 23, 2022
30168bb
chore: update & cleanup modules
soimy Jul 23, 2022
2eaa125
docs: update Docs for txt(.fnt) format and BMFont format description
soimy Jul 23, 2022
986b9cc
chore(release): 2.7.0
soimy Jul 23, 2022
0cb2817
feat: Add arm64 linux compatibility (#89)
tkwiatek Jun 4, 2023
5a2495a
feat: Add arm64 MacOS compatibility (#90)
arilotter Jun 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
.DS_Store
node_modules/
npm-debug.log
test/output/*.json
test/output/*.fnt
test/output/*.png
test/output/*.txt
test/output/*.svg
test/output/*.cfg
test/assets/fonts/*.json
test/assets/fonts/*.fnt
test/assets/fonts/*.png
test/assets/fonts/*.txt
test/assets/fonts/*.svg
test/assets/fonts/*.cfg
.vscode/
.eslintrc*
.prettierrc
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.7.0](https://github.com/soimy/msdf-bmfont-xml/compare/v2.6.0...v2.7.0) (2022-07-23)


### Features

* add new output type: txt ([34d8976](https://github.com/soimy/msdf-bmfont-xml/commit/34d8976a8672045534c8c379c967cf16bcbb8cbe))

## [2.6.0](https://github.com/soimy/msdf-bmfont-xml/compare/v2.5.4...v2.6.0) (2022-01-31)


### Features

* Add version update-notifier ([23aace9](https://github.com/soimy/msdf-bmfont-xml/commit/23aace97c8e4af5174f8191133e42b54baafd0b5))

### [2.5.4](https://github.com/soimy/msdf-bmfont-xml/compare/v2.5.3...v2.5.4) (2020-02-08)


### Bug Fixes

* CLI&document for SVG debug generation from `-t svg` to `-v` ([c37cc40](https://github.com/soimy/msdf-bmfont-xml/commit/c37cc40)), closes [#46](https://github.com/soimy/msdf-bmfont-xml/issues/46)
* omit path in font-face ([ae559fd](https://github.com/soimy/msdf-bmfont-xml/commit/ae559fd)), closes [#49](https://github.com/soimy/msdf-bmfont-xml/issues/49)
* Re-use cfg settings not applied ([3b57562](https://github.com/soimy/msdf-bmfont-xml/commit/3b57562)), closes [#44](https://github.com/soimy/msdf-bmfont-xml/issues/44)



### [2.5.3](https://github.com/soimy/msdf-bmfont-xml/compare/v2.5.2...v2.5.3) (2020-01-26)



### [2.5.2](https://github.com/soimy/msdf-bmfont-xml/compare/v2.5.1...v2.5.2) (2019-07-12)


### Bug Fixes

* async texture generation skips fontData stringify ([230d0b3](https://github.com/soimy/msdf-bmfont-xml/commit/230d0b3)), closes [#39](https://github.com/soimy/msdf-bmfont-xml/issues/39)



### [2.5.1](https://github.com/soimy/msdf-bmfont-xml/compare/v2.5.0...v2.5.1) (2019-07-11)


### Bug Fixes

* async jimp.read() should be fulfilled before continue packing ([5d95b32](https://github.com/soimy/msdf-bmfont-xml/commit/5d95b32))
* package script render changed to yarn ([84732bf](https://github.com/soimy/msdf-bmfont-xml/commit/84732bf))


### Tests

* Fix run render by replacing abandoned devtools ([071b016](https://github.com/soimy/msdf-bmfont-xml/commit/071b016)), closes [#38](https://github.com/soimy/msdf-bmfont-xml/issues/38)



## [2.5.0](https://github.com/soimy/msdf-bmfont-xml/compare/v2.4.3...v2.5.0) (2019-06-19)


### Features

* new border option to control packing space to atlas edge ([33598b9](https://github.com/soimy/msdf-bmfont-xml/commit/33598b9))
101 changes: 57 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,62 @@

[![Build Status](https://travis-ci.org/soimy/msdf-bmfont-xml.svg?branch=master)](https://travis-ci.org/soimy/msdf-bmfont-xml)
[![npm version](https://badge.fury.io/js/msdf-bmfont-xml.svg)](https://badge.fury.io/js/msdf-bmfont-xml)
![npm](https://img.shields.io/npm/dm/msdf-bmfont-xml.svg)

Converts a `.ttf` font file into multichannel signed distance fields, then outputs packed spritesheets and a xml(.fnt} or json representation of an AngelCode BMfont.
Converts 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.

Signed 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).
This 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.

This 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))
![Preview image](https://raw.githubusercontent.com/soimy/msdf-bmfont-xml/master/assets/msdf-bmfont-xml.png)

## Run script to see MSDF font in browser using pixi.js

```bash
npm install & npm run render
```

## Install as CLI

```bash
$ npm install msdf-bmfont-xml -g
npm install msdf-bmfont-xml -g
```

Then you just need to call `msdf-bmfont` from console to generate font file.
Type in `msdf-bmfont --help` for more detail usage.

![Console-Demo](https://raw.githubusercontent.com/soimy/msdf-bmfont-xml/master/assets/console-demo.gif)

### Usage

```
```bash
Usage: msdf-bmfont [options] <font-file>

Creates a BMFont compatible bitmap font of signed distance fields from a font file

Options:

-V, --version output the version number
-f, --output-type <format> font file format: xml(default) | json
-o, --filename <atlas_path> filename of font textures (defaut: font-face)
font filename always set to font-face name
-s, --font-size <fontSize> font size for generated textures (default: 42)
-i, --charset-file <charset> user-specified charactors from text-file
-m, --texture-size <w,h> Width/Height of generated textures (default: 512,512)
-p, --texture-padding <n> padding between glyphs (default: 1)
-r, --distance-range <n> distance range for SDF (default: 4)
-t, --field-type <type> msdf(default) | sdf | psdf | svg
-d, --round-decimal <digit> rounded digits of the output font file. (Defaut: 0)
-v, --vector generate svg vector file for debuging
-u, --reuse [file.cfg] use old config to append font, ommit file to save new cfg
--tolerance <value> use point tolerance to filter problematic vector shape (Defaut: 0)
--smart-size shrink atlas to the smallest possible square (Default: false)
--pot atlas size shall be power of 2 (Default: false)
--square atlas size shall be square (Default: false)
--rtl use RTL(Arabic/Persian) charators fix (Default: false)
-h, --help output usage information
Creates a BMFont compatible bitmap font of signed distance fields from a font file

Options:
-V, --version output the version number
-f, --output-type <format> font file format: xml(default) | json | txt (default: "xml")
-o, --filename <atlas_path> filename of font textures (defaut: font-face)
font filename always set to font-face name
-s, --font-size <fontSize> font size for generated textures (default: 42)
-i, --charset-file <charset> user-specified charactors from text-file
-m, --texture-size <w,h> ouput texture atlas size (default: [2048,2048])
-p, --texture-padding <n> padding between glyphs (default: 1)
-b, --border <n> space between glyphs textures & edge (default: 0)
-r, --distance-range <n> distance range for SDF (default: 4)
-t, --field-type <type> msdf(default) | sdf | psdf (default: "msdf")
-d, --round-decimal <digit> rounded digits of the output font file. (default: 0)
-v, --vector generate svg vector file for debuging
-u, --reuse [file.cfg] save/create config file for reusing settings (default: false)
--smart-size shrink atlas to the smallest possible square
--pot atlas size shall be power of 2
--square atlas size shall be square
--rot allow 90-degree rotation while packing
--rtl use RTL(Arabic/Persian) charactors fix
-h, --help output usage information
```

### Examples
### CLI Examples

Generate 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:

Expand Down Expand Up @@ -79,17 +87,16 @@ How about fire up some graphic editor and add some neat effect and lay on the ou

![final](https://raw.githubusercontent.com/soimy/msdf-bmfont-xml/master/assets/atlas.2.jpg)



## Install as Module

```bash
$ npm install msdf-bmfont-xml
npm install msdf-bmfont-xml
```

## Examples
### Module usage Examples

Writing the distance fields and font data to disk:

```js
const generateBMFont = require('msdf-bmfont-xml');
const fs = require('fs');
Expand All @@ -108,6 +115,7 @@ generateBMFont('Some-Font.ttf', (error, textures, font) => {
```

Generating a single channel signed distance field with a custom character set:

```js
const generateBMFont = require('msdf-bmfont');

Expand All @@ -116,31 +124,34 @@ const opt = {
fieldType: 'sdf'
};
generateBMFont('Some-Font.ttf', opt, (error, textures, font) => {
...
...
});
```

## Usage
### API

#### `generateBMFont(fontPath, [opt], callback)`
#### `generateBMFont(fontPath | fontBuffer, [opt], callback)`

Renders a bitmap font from the font at `fontPath` with optional `opt` settings, triggering `callback` on complete.
Renders a bitmap font from the font specified by `fontPath` or `fontBuffer`, with optional `opt` settings, triggering `callback` on complete.

Options:

- `outputType` (String)
- type of output font file. Defaults to `xml`
- `xml` a BMFont standard .fnt file which is wildly supported.
- `xml` a BMFont standard .fnt file which is wildly supported.
- `json` a JSON file compatible with [Hiero](https://github.com/libgdx/libgdx/wiki/Hiero)
- `filename` (String)
- filename of both font file and font atlas. If omited, font face name is used.
- filename of both font file and font atlas. If omited, font face name is used. **Required** if font is provided as a Buffer.
- `charset` (String|Array)
- the characters to include in the bitmap font. Defaults to all ASCII printable characters.
- the characters to include in the bitmap font. Defaults to all ASCII printable characters.
- `fontSize` (Number)
- the font size at which to generate the distance field. Defaults to `42`
- `textureWidth, textureHeight` (Number)
- the dimensions of an output texture sheet, normally power-of-2 for GPU usage. Both dimensions default to `512`
- `textureSize` (Array[2])
- the dimensions of an output texture sheet, normally power-of-2 for GPU usage. Both dimensions default to `[512, 512]`
- `texturePadding` (Number)
- pixels between each glyph in the texture. Defaults to `2`
- `border` (Number)
- space between glyphs textures & edge. Defaults to `0`
- `fieldType` (String)
- what kind of distance field to generate. Defaults to `msdf`. Must be one of:
- `msdf` Multi-channel signed distance field
Expand All @@ -152,20 +163,22 @@ Options:
- rounded digits of the output font metics. For `xml` output, `roundDecimal: 0` recommended.
- `vector` (Boolean)
- output a SVG Vector file for debugging. Defauts to `false`
- `smart-size` (Boolean)
- `smart-size` (Boolean)
- shrink atlas to the smallest possible square. Default: `false`
- `pot` (Boolean)
- output atlas size shall be power of 2. Default: `false`
- `square` (Boolean)
- output atlas size shall be square. Default: `false`
- `rot` (Boolean)
- allow 90-degree rotation while packing. Default: `false`
- `rtl` (Boolean)
- use RTL(Arabic/Persian) charators fix. Default: `false`

The `callback` is called with the arguments `(error, textures, font)`

- `error` on success will be null/undefined
- `textures` an array of js objects of texture spritesheet.
- `textures[index].filename` Spritesheet filename
- `textures[index].filename` Spritesheet filename
- `textures[index].texture` Image Buffers, containing the PNG data of one texture sheet
- `font` an object containing the BMFont data, to be used to render the font
- `font.filename` font filename
Expand Down
52 changes: 52 additions & 0 deletions assets/charset/charset.arabic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ببب ب
تتت ت
ضضض ض
صصص ص
ثثث ث
ققق ق
ففف ف
غغغ غ
ععع ع
ههه ه
ـة ة
خخخ خ
ححح ح
ججج ج
چچچ چ
ششش ش
سسس س
ئئئ ئ
ىىـی ى
ييي ي
ببب ب
للل ل
ء
ـأأ
ـإإ
ـاا
ـآآ
لا
ـلا
لأ
ـلأ
لإ
ـلإ
لآ
ـلآ
ننن ن
ممم م
ككك ك
ککک ک
گگگ گ
ظظظ ظ
ططط ط
ـزز
ـرر
ـژژ
ـوو
ـذذ
ـدد
پپپ پ
َُِّ
":><؟{}|+_()&*!@#$%×÷÷`|;'[].,/\،-=
12345567890
Binary file added bin/darwin_arm64/msdfgen.osx
Binary file not shown.
Binary file modified bin/linux/msdfgen.linux
Binary file not shown.
Binary file added bin/linux_arm64/msdfgen.linux
Binary file not shown.
Loading