feat: sentences only mode

This commit is contained in:
2026-11-08 00:20:51 +01:00
parent 402f5c1405
commit 4781a1b34f
4 changed files with 21 additions and 7 deletions
+5 -3
View File
@@ -7,9 +7,9 @@
## 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] [-v | --verbose | --no-verbose]
[-q | --quiet | --no-quiet]
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]
[-v | --verbose | --no-verbose] [-q | --quiet | --no-quiet]
options:
-h, --help show this help message and exit
@@ -27,6 +27,8 @@ options:
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)
-v, --verbose, --no-verbose
more verbose logging
-q, --quiet, --no-quiet
+5 -3
View File
@@ -13,9 +13,11 @@ def main() -> int:
setup_logs(params)
logging.getLogger().info("%s %s", PKG_NAME, PKG_VERSION)
glyphs, sets, sentences = Reader(params).read()
Generator(params).generate_glsl_glyphs(glyphs, sets)
if not params.sentences_only:
glyphs, sets, sentences = Reader(params).read()
Generator(params).generate_glsl_glyphs(glyphs, sets)
else:
sentences = Reader(params).read_sentences()
if len(sentences):
Generator(params).generate_glsl_sentences(sentences)
+7 -1
View File
@@ -15,6 +15,7 @@ class Parameters:
functions: bool = False
source_sentences_path: str | None = None
target_sentences_path: str | None = None
sentences_only: bool = False
verbose: bool = False
quiet: bool = False
@@ -32,7 +33,6 @@ def parse_parameters(args: typing.Sequence[str]) -> Parameters:
parser.add_argument(
"-i",
"--input",
required=True,
metavar="INPUT_FILE",
dest="source_image_path",
help="png 8x8 glyph map",
@@ -85,6 +85,12 @@ def parse_parameters(args: typing.Sequence[str]) -> Parameters:
dest="target_sentences_path",
help="output sentences glsl file (default: build/{name}_sentences.glsl)",
)
parser.add_argument(
"--sentences-only",
action=argparse.BooleanOptionalAction,
default=default_values.verbose,
help="generate only sentences from names (does not read input image)",
)
parser.add_argument(
"-v",
"--verbose",
+4
View File
@@ -42,6 +42,10 @@ class Reader:
return glyphs, sets, sentences
def read_sentences(self) -> list[Sentence]:
names = self.__read_names()
return self.__read_sentences(names)
def __read_image(self) -> list[Glyph]:
try:
img = Image.open(self.source_image_path).convert("1")