Improve docs and metadata

This commit is contained in:
elpekenin 2024-02-17 19:22:37 +01:00
parent 20a4e11742
commit 3903c70035
3 changed files with 9 additions and 11 deletions

View File

@ -796,3 +796,4 @@ This command converts a TTF font to an intermediate format for editing, before c
## `qmk painter-convert-font-image` ## `qmk painter-convert-font-image`
This command converts an intermediate font image to the QFF File Format. See the [Quantum Painter](quantum_painter.md?id=quantum-painter-cli) documentation for more information on this command. This command converts an intermediate font image to the QFF File Format. See the [Quantum Painter](quantum_painter.md?id=quantum-painter-cli) documentation for more information on this command.

View File

@ -115,8 +115,7 @@ This command converts a TTF font to a QFF File Format.
**Usage**: **Usage**:
``` ```
usage: qmk painter-convert-font [-h] [-w] [-u UNICODE_GLYPHS] [-s SIZE] [-o OUTPUT] [-i INPUT] -f FORMAT usage: qmk painter-convert-font [-h] [-w] [-u UNICODE_GLYPHS] [-s SIZE] [-o OUTPUT] [-i INPUT] -f FORMAT [-r] [-n] [-a]
[-r] [-n] [-a]
options: options:
-h, --help show this help message and exit -h, --help show this help message and exit
@ -129,8 +128,7 @@ options:
-i INPUT, --input INPUT -i INPUT, --input INPUT
Specify input font file. Specify input font file.
-f FORMAT, --format FORMAT -f FORMAT, --format FORMAT
Output format, valid types: rgb888, rgb565, pal256, pal16, pal4, pal2, mono256, Output format, valid types: rgb888, rgb565, pal256, pal16, pal4, pal2, mono256, mono16, mono4, mono2
mono16, mono4, mono2
-r, --no-rle Disable the use of RLE to minimise converted image size. -r, --no-rle Disable the use of RLE to minimise converted image size.
-n, --no-ascii Disables output of the full ASCII character set (0x20..0x7E), exporting only the -n, --no-ascii Disables output of the full ASCII character set (0x20..0x7E), exporting only the
glyphs specified. glyphs specified.
@ -159,8 +157,7 @@ options:
-a, --no-aa Disable anti-aliasing on fonts. -a, --no-aa Disable anti-aliasing on fonts.
-u UNICODE_GLYPHS, --unicode-glyphs UNICODE_GLYPHS -u UNICODE_GLYPHS, --unicode-glyphs UNICODE_GLYPHS
Also generate the specified unicode glyphs. Also generate the specified unicode glyphs.
-n, --no-ascii Disables output of the full ASCII character set (0x20..0x7E), exporting only the -n, --no-ascii Disables output of the full ASCII character set (0x20..0x7E), exporting only the glyphs specified.
glyphs specified.
-s SIZE, --size SIZE Specify font size. Default 12. -s SIZE, --size SIZE Specify font size. Default 12.
-o OUTPUT, --output OUTPUT -o OUTPUT, --output OUTPUT
Specify output image path. Specify output image path.
@ -197,16 +194,14 @@ This command expects an image that conforms to the following format:
**Usage**: **Usage**:
``` ```
usage: qmk painter-convert-font-image [-h] [-w] [-r] -f FORMAT [-u UNICODE_GLYPHS] [-n] [-o OUTPUT] usage: qmk painter-convert-font-image [-h] [-w] [-r] -f FORMAT [-u UNICODE_GLYPHS] [-n] [-o OUTPUT] [-i INPUT]
[-i INPUT]
options: options:
-h, --help show this help message and exit -h, --help show this help message and exit
-w, --raw Writes out the QFF file as raw data instead of c/h combo. -w, --raw Writes out the QFF file as raw data instead of c/h combo.
-r, --no-rle Disable the use of RLE to minimise converted image size. -r, --no-rle Disable the use of RLE to minimise converted image size.
-f FORMAT, --format FORMAT -f FORMAT, --format FORMAT
Output format, valid types: rgb888, rgb565, pal256, pal16, pal4, pal2, mono256, Output format, valid types: rgb888, rgb565, pal256, pal16, pal4, pal2, mono256, mono16, mono4, mono2
mono16, mono4, mono2
-u UNICODE_GLYPHS, --unicode-glyphs UNICODE_GLYPHS -u UNICODE_GLYPHS, --unicode-glyphs UNICODE_GLYPHS
Also generate the specified unicode glyphs. Also generate the specified unicode glyphs.
-n, --no-ascii Disables output of the full ASCII character set (0x20..0x7E), exporting only the -n, --no-ascii Disables output of the full ASCII character set (0x20..0x7E), exporting only the

View File

@ -3,6 +3,7 @@
import datetime import datetime
import math import math
import re import re
import sys
from string import Template from string import Template
from PIL import Image, ImageOps from PIL import Image, ImageOps
@ -151,10 +152,11 @@ def generate_subs(cli, out_bytes, *, font_metadata=None, image_metadata=None):
} }
if font_metadata is not None: if font_metadata is not None:
command = sys.argv[1] # extract whether we are in `painter-convert-font` or `painter-convert-font-image`
subs.update({ subs.update({
"generated_type": "font", "generated_type": "font",
"var_prefix": "font", "var_prefix": "font",
"generator_command": f"qmk painter-convert-font-image -i {cli.args.input.name} -f {cli.args.format}{' --no-ascii' if cli.args.no_ascii else ''}", "generator_command": f"qmk {command} -i {cli.args.input.name} -f {cli.args.format}{' --no-ascii' if cli.args.no_ascii else ''}",
# not using triple quotes to avoid extra indentation/weird formatted code # not using triple quotes to avoid extra indentation/weird formatted code
"metadata": "\n".join([ "metadata": "\n".join([
"// Font's metadata", "// Font's metadata",