Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16b52e8fc7 | ||
|
|
a9d250944b | ||
|
|
14230bd489 | ||
|
|
9978de6cdf | ||
|
|
b4b2e2a5f1 | ||
|
|
051b1f0060 | ||
|
|
30955a3f46 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "glsl-glyphs"
|
||||
version = "1.0.0"
|
||||
version = "1.0.2"
|
||||
description = "Generate GLSL ready glyph maps and usable functions "
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.14"
|
||||
|
||||
@@ -3,7 +3,7 @@ index,length,name
|
||||
38,3,HEARTS
|
||||
36,36,OBJECTS
|
||||
96,20,SELECT
|
||||
120,12,CHAT
|
||||
122,10,CHAT
|
||||
132,12,EMOTION
|
||||
144,42,TILES
|
||||
186,6,SQUARES
|
||||
|
||||
|
@@ -102,9 +102,11 @@ class Generator:
|
||||
try:
|
||||
self.target_sentences_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
self.target_sentences_path.write_text(content)
|
||||
self.log.info("Wrote sentences output to %s", self.target_path)
|
||||
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_path, e
|
||||
"Could not write sentences output file at: %s (%s)",
|
||||
self.target_sentences_path,
|
||||
e,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -39,10 +39,14 @@ class Reader:
|
||||
def read(self) -> tuple[list[Glyph], list[GlyphSet], list[Sentence]]:
|
||||
glyphs = self.__read_image()
|
||||
names = self.__read_names()
|
||||
sets = self.__read_sets()
|
||||
|
||||
for glyph, name in zip(glyphs, names, strict=False):
|
||||
glyph.name = name
|
||||
|
||||
if self.add_all:
|
||||
sets.insert(0, GlyphSet(index=0, length=len(glyphs), name="ALL"))
|
||||
|
||||
if self.add_empty and "EMPTY" not in names:
|
||||
if len(glyphs) >= MAX_GLYPHS:
|
||||
self.log.error(
|
||||
@@ -51,11 +55,8 @@ class Reader:
|
||||
sys.exit(1)
|
||||
glyphs.insert(0, Glyph(data=[0] * 4, name="EMPTY"))
|
||||
names.insert(0, "EMPTY")
|
||||
|
||||
sets = self.__read_sets()
|
||||
|
||||
if self.add_all:
|
||||
sets.insert(0, GlyphSet(index=0, length=len(glyphs), name="ALL"))
|
||||
for glyphset in sets:
|
||||
glyphset.index += 1
|
||||
|
||||
sentences = self.__read_sentences(names)
|
||||
|
||||
@@ -67,9 +68,7 @@ class Reader:
|
||||
|
||||
def __read_image(self) -> list[Glyph]:
|
||||
if not self.source_image_path:
|
||||
self.log.error(
|
||||
"No input image provided"
|
||||
)
|
||||
self.log.error("No input image provided")
|
||||
sys.exit(1)
|
||||
try:
|
||||
img = Image.open(self.source_image_path).convert("1")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user