From a9d250944bef1b00fde1ba380288dd731d5151a1 Mon Sep 17 00:00:00 2001 From: klemek Date: Wed, 11 Nov 2026 17:59:23 +0100 Subject: [PATCH] fix: sentences generation with spaces --- src/glsl_glyphs/generator.py | 4 +++- src/glsl_glyphs/sentences.py | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/glsl_glyphs/generator.py b/src/glsl_glyphs/generator.py index 3196b91..5e83fd2 100644 --- a/src/glsl_glyphs/generator.py +++ b/src/glsl_glyphs/generator.py @@ -105,6 +105,8 @@ class Generator: self.log.info("Wrote sentences output to %s", self.target_sentences_path) except OSError as e: self.log.error( - "Could not write sentences output file at: %s (%s)", self.target_sentences_path, e + "Could not write sentences output file at: %s (%s)", + self.target_sentences_path, + e, ) sys.exit(1) diff --git a/src/glsl_glyphs/sentences.py b/src/glsl_glyphs/sentences.py index 8d1064d..b4ef764 100644 --- a/src/glsl_glyphs/sentences.py +++ b/src/glsl_glyphs/sentences.py @@ -49,15 +49,15 @@ class Sentence: @classmethod def from_text(cls, src_text: str, names: list[str]) -> Sentence: text = src_text - if "EMPTY" in names: - text = text.replace(" ", "{EMPTY}") - else: - log.warning("No EMPTY tile in names, removing spaces in '%s'", src_text) - text.replace(" ", "") changed = True data = [] remaining_text = "" - while changed: + + while changed and len(text): + if text[0] == " " and "EMPTY" in names: + text = text[1:] + data += [names.index("EMPTY")] + continue changed = False min_name = None min_pattern = None