Files
glsl-glyphs/README.md
T
klemek 5fe201e2f8
Python Lint CI / ruff (push) Successful in 5m39s
Python Lint CI / ty (push) Successful in 5m36s
Python Lint CI / ruff-format-check (push) Failing after 5m37s
feat: --add-all
2026-11-08 13:27:30 +01:00

124 lines
4.2 KiB
Markdown

[![](https://git.klemek.fr/klemek/glsl-glyphs/actions/workflows/lint.yml/badge.svg?branch=main&style=flat-square)](https://git.klemek.fr/klemek/glsl-glyphs/actions?workflow=lint.yml)
# GLSL Glyphs Generator
> Generate GLSL ready 8x8 glyph maps and usable functions.
Reads each 8x8 glyph into 4x4 squares then converts them into (0-65535) integers.
```txt
██████ 0x151E, 0x8A87, 0xE19D, 0x789B,
█ █
█ █ █ █ ███ ███ █ ██ ██ █
█ █ -> █ █ █ █ █ █
█ ████ █ █ █ █ █ █ █
█ ██ █ █ █ ███ ███
█ █
██████
```
Writes it into GLSL ready files to use it easily in shaders
```glsl
const int cp437_glyphs[] = int[1024](
0x0000, 0x0000, 0x0000, 0x0000, // 0x00, EMPTY
0x151E, 0x8A87, 0xE19D, 0x789B, // 0x01, SMILEY
// ...
);
bool cp437(vec2 pos, int code)
{
// ...
}
```
## Usage
```txt
usage: glsl-glyphs [-h] [-i INPUT_FILE] [-n NAME] [-o OUTPUT_FILE] [-g NAMES_FILE] [-s SETS_FILE] [-f | --functions | --no-functions]
[--sentences-input SENTENCES_FILE] [--sentences-output OUTPUT_FILE] [--sentences-only | --no-sentences-only]
[--includes | --no-includes] [--add-empty | --no-add-empty] [--add-all | --no-add-all] [-v | --verbose | --no-verbose]
[-q | --quiet | --no-quiet]
options:
-h, --help show this help message and exit
-i, --input INPUT_FILE
png 8x8 glyph map
-n, --name NAME target derived name for GLSL constants and functions (default: glyph)
-o, --output OUTPUT_FILE
output glyphs glsl file (default: build/{name}.glsl}
-g, --glyph-names NAMES_FILE
glyphs names, one line each
-s, --sets SETS_FILE defined sets in CSV: index,length,name
-f, --functions, --no-functions
add GLSL functions to output
--sentences-input SENTENCES_FILE
generate sentences from file and names
--sentences-output OUTPUT_FILE
output sentences glsl file (default: build/{name}_sentences.glsl)
--sentences-only, --no-sentences-only
generate only sentences from names (does not read input image)
--includes, --no-includes
use #include preprocessor in GLSL (forge)
--add-empty, --no-add-empty
add EMPTY tile at start of tileset if missing
--add-all, --no-add-all
add ALL set at start list
-v, --verbose, --no-verbose
more verbose logging
-q, --quiet, --no-quiet
disable logging
```
## More info about included samples
### IBM PC CP437
See [Why is there a "small house" in IBM's Code page 437?](https://blog.glyphdrawing.club/why-is-there-a-small-house-in-ibm-s-code-page-437/) for more info on IBM PC CP437.
### Crystalwarrior
See [1 bit by Crystalwarrior](https://alex-noir.itch.io/1-bit-by-cw)
### Pmlomb
See [8x8 1 bit pixel set](https://opengameart.org/content/8x8-1-bit-pixel-set)
## Development
### Makefile
```txt
Usage: make [target1] [target2] ...
Commands/Targets:
help show this message
install install project
update update project dependencies
run run project
sample-all generate all samples
sample-% generate sample (cp437/cw/pmlomb)
format format project
lint lint project
build build project
uv-sync uv sync
uv-upgrade uv sync upgrade
uv-run uv run (project)
uv-run-sample-% uv run (project) sample/(xxx)
ruff ruff check
ruff-fix ruff check (and fix)
ruff-format ruff format
ruff-format-check ruff format (check only)
ty ty check
release-% release major/minor/patch
```
### TODO
* [x] Initial implementation
* [x] Generate a separate sentences file
* [ ] Custom height glyph map
* [ ] Custom width glyph map
* [ ] More compact data using GLSL ints
* [ ] separated sets/patterns