the image2font script

image2font is a image's converter to font written in fontforge's python script.

usage

short example:

git clone https://github.com/limaconoob/Image2font.git image2font && cd image2font
python image2font --input-font tests/assets/ttf/sazanami-gothic.ttf tests/assets/neko_wikipe-tan.png
cp -f sazanami-gothic.ttf $HOME/.local/share/fonts

with docker

to more detail, see docker branch:

git clone -b docker https://github.com/limaconoob/Image2font.git image2font && cd image2font
make build run

export IMAGES=neko.png
export FONT_INPUT=sazanami-gothic.ttf
export FONT_OUTPUT=neko.ttf

docker cp $IMAGES $(make get):/root/image2font/$IMAGES
docker cp $FONT_INPUT $(make get):/root/image2font/$FONT_INPUT
docker exec $(make get) python image2font --input-font $FONT_INPUT --output-font $FONT_OUTPUT $IMAGES
docker cp $(make get):/root/image2font/$FONT_OUTPUT $FONT_OUTPUT
cp -f $FONT_OUTPUT $HOME/.local/share/fonts

CLI

see command help:

Usage:  [options] [IMAGES]...

  Options:
    --version             show program's version number and exit
    -h, --help            show this help message and exit
    -w GRID_WIDTH, --grid-width=GRID_WIDTH
                          Sets the cell width unity from picture.
    -a GRID_HEIGHT, --grid-heigth=GRID_HEIGHT
                          Sets the cell height unity from picture.
    -c CELL_WIDTH, --cell-width=CELL_WIDTH
                          Sets the cell width pixel from picture.
    -b CELL_HEIGHT, --cell-heigth=CELL_HEIGHT
                          Sets the cell height pixel from picture.
    -i INPUT, --input-font=INPUT
                          Modify this existent font.
    -o OUTPUT, --output-font=OUTPUT
                          Specify the namefont to create.
    -s INDEX, --start-index=INDEX
                          Start to write the glyphs at 0xE000's index if there
                          is `input-font` else at 0x0000.
    -n NAME, --name-font=NAME
                          Is the name of font.