A collection of command-line utilities NES system development.
nes_tools provides two complementary tools for NES asset creation:
- png2chr: Converts PNG images to NES CHR (character) format
- ttf2png: Renders TrueType fonts to PNG grids compatible with NES tools
Converts indexed-color PNG images into NES CHR (CHRacter) format, used for sprite and background tile data.
- Converts 8x8 pixel tiles to NES 2-bitplane CHR format
- Supports palette-based PNG images
- Validates input dimensions (must be multiples of 8x8)
- Handles 2-bit color depth (4 colors per tile)
- Comprehensive error reporting
png2chr <input.png> <output.chr>- Input PNG Format:
- Must be indexed color (palette-based)
- Dimensions must be multiples of 8x8 pixels
- Palette colors: 0-3 (2 bits per pixel)
- Each 8x8 tile is converted to 16 bytes in CHR format
png2chr tileset.png output.chrRenders characters from a TrueType font into a PNG grid, creating font bitmaps suitable for NES applications.
- Renders individual characters from TTF fonts to a customizable PNG grid
- Supports configurable character dimensions
- Creates 8-bit indexed color PNG output
- Flexible grid layout (width × height)
- Handles various font files with proper glyph rendering
ttf2png -chars:<characters> -width:<cols> -height:<rows> [-char_width:<w>] [-char_height:<h>] <input.ttf> <output.png>| Argument | Description | Default |
|---|---|---|
-chars:<characters> |
Characters to render (required) | - |
-width:<cols> |
Grid width (number of columns) | - |
-height:<rows> |
Grid height (number of rows) | - |
-char_width:<w> |
Character pixel width | 8 |
-char_height:<h> |
Character pixel height | 8 |
<input.ttf> |
Path to TrueType font file (required) | - |
<output.png> |
Path to output PNG file (required) | - |
- PNG Type: Indexed color, 8-bit
- Palette: 2-color (black and white)
- Grid Size: `width × height` characters
- Image Size: `(width × char_width) × (height × char_height)` pixels
ttf2png -chars:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -width:8 -height:5 -char_width:8 -char_height:16 font.ttf font_output.pngThis creates a 8×5 grid (40 characters) with 8×16 pixel characters, resulting in an 64×80 pixel PNG.
The project uses CMake for building. Ensure you have the required dependencies installed:
- libpng: PNG image manipulation
- FreeType2: Font rasterization (ttf2png only)
- C99 or later: Required for compilation
mkdir build
cd build
cmake ..
makeExecutables will be created in the `build/` directory.
A typical workflow for creating NES fonts:
-
Render TTF to PNG:
ttf2png -chars:ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -width:8 -height:5 font.ttf font.png
-
Convert PNG to CHR:
png2chr font.png font.chr
The project includes sample fonts in `data_test/ttf2png/`:
- PressStart2P-Regular.ttf
- PixelifySans-Regular.ttf
- VT323-Regular.ttf
- PixeloidMono.ttf
- Ithaca-LVB75.ttf
- And more...
Sample PNG for testing png2chr is located in `data_test/png2chr/`.