gsfnt 0.1.0

Pack a folder of images into BMFont (.fnt) and a merged PNG atlas
# gsfnt

CLI tool that packs all images in a directory into a **BMFont** text `.fnt` file plus a single merged **RGBA PNG** atlas. Each glyph’s Unicode code point is taken from the **first character** of the image filename stem (the part before the extension).

## Install

```bash
cargo install gsfnt
```

Or build from this repository:

```bash
cargo build --release
# binary: target/release/gsfnt
```

## Usage

```bash
gsfnt --input /path/to/images --output /path/to/out/font
```

This writes:

- `font.fnt` — AngelCode-style BMFont (text format)
- `font.png` — atlas image referenced by the `.fnt`

If `--output` already ends with `.fnt`, that path is used as-is and the PNG is the same path with `.png`.

### Options

| Option | Description |
|--------|-------------|
| `-i`, `--input` | Directory containing source images |
| `-o`, `--output` | Output prefix (see above) |
| `--max-width` | Maximum row width for shelf packing (default: `4096`) |

### Supported image extensions

`png`, `jpg`, `jpeg`, `webp`, `gif`, `bmp`

### Filename → glyph

- `A.png` → glyph for `A` (U+0041)
- `中.png` → glyph for ``
- `emoji_rest.png` → glyph for the first character only (`e`)

Duplicate code points (two files mapping to the same first character) are rejected with an error listing both paths.

### Font metrics (output)

- `lineHeight` / `base` = maximum image height among all glyphs
- `xoffset` = 0
- `yoffset` = `lineHeight - height` (bottom-aligned within the line box)
- `xadvance` = glyph width

## License

MIT. See [LICENSE](LICENSE).