ws-apifix: an outline font saved as BMFont writes its pages (opts.files; without a destination F.save returns them as a third value { [page file] = PNG bytes }; caps.extraFiles); pages named after the destination

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
4DBugandClaude Opus 5.5 committed 2026-10-31 14:03:45 -05:00
1 parent 4557a3c792
commit 2abada340b
6 files changed
+83 -9

No files matched your search

+12 -2
View File
@@ -219,8 +219,18 @@ local again = assert(F.font.load(bin, { pages = baked.pages }))
assert(again:advance(again:glyphIndex(string.byte("H"))) == baked:advance(baked:glyphIndex(string.byte("H"))))
```
`F.save(ttf, nil, { format = "bmfont", px = 16 })` bakes too, but returns only the descriptor: the page images are
not written anywhere. Use `bake` when you need the pages.
`F.save(ttf, dest, { format = "bmfont", px = 16, chars = ... })` bakes too, and writes the page PNGs next to the
`.fnt`, named after it (`ui.fnt` gets `ui_0.png`, ...; `file` sets another prefix). Without a destination it
returns the pages as a third value, `{ [page file name] = PNG buffer }` (the names the descriptor uses), or puts
them into your `opts.files` table when you pass one. A BMFont whose pages are loaded saves them the same way.
```luau
local ttf = assert(F.font.load(ttfBytes))
local fnt, _, pages = F.save(ttf, nil, { format = "bmfont", px = 16, chars = "Hi", file = "hud" })
assert(fnt and pages and F.detect(pages["hud_0.png"]) == "png")
local bm = assert(F.font.load(fnt, { loadPage = function(file) return pages[file] end }))
assert(bm:rasterize(bm:glyphIndex(string.byte("H"))))
```
## Formats