mirror of
https://github.com/GearsProgress/Poke_Transporter_GB.git
synced 2026-04-26 10:17:40 -05:00
Maintaining spaces after punctuation
This commit is contained in:
parent
ce99437bc9
commit
5ce9a0c470
|
|
@ -92,16 +92,13 @@ def split_into_sentences(text: str) -> list[str]:
|
||||||
return sentences
|
return sentences
|
||||||
|
|
||||||
def split_sentence_into_lines(sentence, offset, pixelsPerChar, pixelsInLine, lang):
|
def split_sentence_into_lines(sentence, offset, pixelsPerChar, pixelsInLine, lang):
|
||||||
# If we can optimize this to remove the spaces, it could save a few bytes.
|
|
||||||
splitChars = [' ']
|
|
||||||
outStr = ""
|
outStr = ""
|
||||||
currLine = ""
|
currLine = ""
|
||||||
lineCount = 0
|
lineCount = 0
|
||||||
currWordIndex = 0
|
currWordIndex = 0
|
||||||
lineLength = 0
|
lineLength = 0
|
||||||
spaceLength = 0
|
spaceLength = 0
|
||||||
for char in splitChars:
|
|
||||||
sentence = sentence.replace(char, " ")
|
|
||||||
words = sentence.split()
|
words = sentence.split()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -152,8 +149,13 @@ def split_sentence_into_lines(sentence, offset, pixelsPerChar, pixelsInLine, lan
|
||||||
# Test if adding the word will go over our alloted space
|
# Test if adding the word will go over our alloted space
|
||||||
elif ((wordLength + lineLength + offset) <= pixelsInLine):
|
elif ((wordLength + lineLength + offset) <= pixelsInLine):
|
||||||
# If not, add the word and increase the index
|
# If not, add the word and increase the index
|
||||||
currLine += (word + " ")
|
if (currWordIndex == (len(words) - 1)):
|
||||||
lineLength += (wordLength + spaceLength)
|
# Don't add a space to the end of the sentence.
|
||||||
|
currLine += word
|
||||||
|
lineLength += wordLength
|
||||||
|
else:
|
||||||
|
currLine += (word + " ")
|
||||||
|
lineLength += (wordLength + spaceLength)
|
||||||
currWordIndex += 1
|
currWordIndex += 1
|
||||||
|
|
||||||
# We need to move to the next line
|
# We need to move to the next line
|
||||||
|
|
@ -181,7 +183,8 @@ def convert_char_to_byte(incoming, array, lang):
|
||||||
if str(val) == chr(incoming):
|
if str(val) == chr(incoming):
|
||||||
return index
|
return index
|
||||||
index += 1
|
index += 1
|
||||||
log_warning_error(lang, "Error", f"No match found for char [ {chr(incoming)} ]!")
|
if chr(incoming) != '_':
|
||||||
|
log_warning_error(lang, "Error", f"No match found for char [ {chr(incoming)} ]!")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def log_warning_error(lang, type, text):
|
def log_warning_error(lang, type, text):
|
||||||
|
|
@ -221,6 +224,12 @@ def convert_item(ogDict, lang):
|
||||||
line = line.replace(pair[0], escapeString)
|
line = line.replace(pair[0], escapeString)
|
||||||
#print(line)
|
#print(line)
|
||||||
|
|
||||||
|
# Change all the punctuation marks followed by spaces into being followed by _ .
|
||||||
|
# These will end up being replaced by spaces anyway in the end (but ignore the error)
|
||||||
|
puncts = ['.']
|
||||||
|
for punct in puncts:
|
||||||
|
line = line.replace(punct + " ", punct + "_")
|
||||||
|
|
||||||
split_sents = split_into_sentences(line)
|
split_sents = split_into_sentences(line)
|
||||||
index = 0
|
index = 0
|
||||||
outStr = ""
|
outStr = ""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user