Expand description
font-atlas [--no-text] [--wide [<set>=]<wide.bdf>]... <font.bdf>... <out-dir>: turns a BDF
bitmap font into a
font atlas (atlas.png + atlas.ron, read as
shuyi_assets::font::FontAtlasDef) and its one-bit copy for a one-bit
screen (atlas_1bit.bin). It keeps the glyphs the font has of
ATLAS_RANGES, of the characters the game’s text uses and of the
glyphs the project requires (AtlasChars): when shuyi.ron names a
game tool program, font-atlas runs in it and reads the game’s text
(--no-text: the ranges and the required glyphs only). Further BDF
files add glyphs the first lacks (a game’s own, e.g. controller button
shapes). The atlas must have the glyphs the project requires
(crate::project::FontAtlas::required_glyphs); a character the text
uses that the fonts lack is named, and check fails on it.
--wide adds a wide font (Japanese, Chinese), its cells twice as wide
as the narrow font’s: the atlas keeps its glyphs of the characters the
text uses that the narrow fonts lack, and of the project’s
wide_glyphs, each over two cells after the narrow glyphs. A BDF font
in JIS X 0208 (CHARSET_REGISTRY "JISX0208...") is read as Unicode,
with the crate’s jis feature (without it, such a font is refused).
--wide <set>=<wide.bdf> makes a named wide set instead, and may be
given once per set (WideFont): the set keeps the wide characters of
the languages that name it (a pack’s lang.ron’s wide_font, the
source’s SourceLang::wide_font), their wide punctuation if they have
it wide, and the project’s
wide_set_glyphs for it. An unnamed --wide keeps those of the
languages that name no set. The sets are laid out one after another,
in the order given, after the narrow glyphs.
Structs§
- Atlas
- The atlas: the glyph map, plus its picture (white where the glyph is set, transparent elsewhere).
- Atlas
Chars - The characters an atlas keeps, of those its font has: every one of
ATLAS_RANGES, every character the game’s text uses, and the glyphs the project requires; never a combining mark or a control character. Its wide sets keep the characters of the languages that draw from them (wants_wide).AtlasChars::defaultis the ranges alone. - Bitmap
Font - A bitmap font: fixed cell size, each glyph an on/off pixel grid placed
inside the cell (row-major,
cell_w × cell_h). - Wide
Font - A wide font
font-atlasreads: the set it makes and its BDF file.
Constants§
- ATLAS_
RANGES - Unicode ranges copied into the atlas (whatever the font has of them).
- COLUMNS
- Atlas cells per row.
- ONE_
BIT_ FILE - The one-bit atlas’s file name, next to
atlas.png.
Functions§
- atlas_
ron - The
atlas.rontext fordef, with a generated-file header naming the tool ascommandand pointing atreadme, if there is one. - build_
atlas - Lays out every glyph of
fontthatcharswants, in codepoint order,COLUMNSper row. - build_
atlas_ with_ sets build_atlas, and after the narrow glyphs each wide set ofwides(None: the unnamed one) in turn: the glyphs of its font thatcharswants in it (AtlasChars::wants_wide), in codepoint order, each over two cells of one row. A wide font’s cells must be twice as wide asfont’s and as tall (check_wide).- build_
wide_ atlas build_atlas, and after the narrow glyphs the glyphs ofwidethatcharswants wide (AtlasChars::wants_wide), in codepoint order, each over two cells of one row: the unnamed wide set.build_atlas_with_setssays more.- check_
wide - Whether
widefits besidefontas its wide font: its cells twice as wide and as tall. - one_bit
- The one-bit atlas (
ONE_BIT_FILE) of the atlas pictureimagelaid out asdef: each glyph in cell index order, one byte per pixel row, the highest bit the left pixel, set where the picture isn’t see-through; a wide glyph’s two halves are two cells like any other. Fails for cells wider than 8 pixels. - parse_
bdf - Parses a BDF font. Glyph bitmaps are positioned in the cell using the
font and glyph bounding boxes; pixels outside the cell are dropped. A
font whose
CHARSET_REGISTRYis JIS X 0208’s has its codes read as Unicode (with thejisfeature; refused without it); a code with no Unicode character is left out. - read_
font - Reads and parses the BDF font at
path. - run
- Runs the command: reads the fonts at
font_paths(the first is the font; the rest add glyphs to it) and the wide fontswides, each its own set (one set once), and writes the glyphscharswants toatlas.png,atlas.ronandatlas_1bit.bininout_dir. Fails if the result lacks a glyphrulesrequire; a character the text uses that the fonts lack is named in the summary, not a failure.commandis whatatlas.ron’s header calls the tool.