This commit is contained in:
2025-01-17 18:23:11 +01:00
parent 8de55017f9
commit 2f56f0a633
2 changed files with 25 additions and 16 deletions

10
main.py
View File

@@ -340,7 +340,7 @@ def main(data: dict):
new_text.append("")
text_words = t.split(" ")
for w in text_words:
res = re.findall(r"\[(.*?)\/(\d)\]([^\[ ]*)",w)
res = re.findall(r"([^\] ]*)\[(.*?)\/(\d)\]([^\[ ]*)",w)
if res == []:
new_text = add_to_text(new_text,w)
else:
@@ -348,19 +348,19 @@ def main(data: dict):
new_text = add_to_text(new_text,"")
for slot in res:
new_text = add_to_text(new_text,WORD_SLOT_SPACING+slot[2],"")
new_text = add_to_text(new_text,slot[0]+WORD_SLOT_SPACING+slot[3],"")
height = WORD_FONT_SIZE*len(new_text)
width, _ = font.size(new_text[-1])
extra_width, _ = font.size(slot[2])
extra_width, _ = font.size(slot[3])
pos = Vector2(
TEXT_MARGIN + width - extra_width - WORD_WIDTH,
TEXT_MARGIN + height - WORD_HEIGHT//2 + TEXT_TOP_MARGIN*len(new_text) + WORD_SLOT_NUDGE_DOWN
)
# if new_text[-1] != WORD_SLOT_SPACING+slot[2]:
pos.x += WORD_SLOT_NUDGING
new_slot = WordSlot(WordColor(int(slot[1])),p,pos)
new_slot = WordSlot(WordColor(int(slot[2])),p,pos)
word_slots.append(new_slot)
p.slots.append((slot[0].replace("%"," "),new_slot))
p.slots.append((slot[1].replace("%"," "),new_slot))
p.text = new_text