Skip to content

Commit

Permalink
Wrap hyphenator exceptions (Closes #500)
Browse files Browse the repository at this point in the history
  • Loading branch information
thatDudo committed Nov 13, 2023
1 parent 5be1450 commit 11b3a39
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions manga_translator/rendering/text_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ def select_hyphenator(lang: str):
break
else:
return None
return Hyphenator(lang)
try:
return Hyphenator(lang)
except Exception:
return None

# @functools.lru_cache(maxsize = 1024, typed = True)
def get_char_offset_x(font_size: int, cdpt: str):
Expand Down Expand Up @@ -403,8 +406,11 @@ def calc_horizontal(font_size: int, text: str, max_width: int, max_height: int,
hyphenator = select_hyphenator(language)
for i, word in enumerate(words):
new_syls = []
if hyphenator:
new_syls = hyphenator.syllables(word)
if hyphenator and len(word) <= 100:
try:
new_syls = hyphenator.syllables(word)
except Exception:
new_syls = []
if len(new_syls) == 0:
if len(word) <= 3:
new_syls = [word]
Expand Down

0 comments on commit 11b3a39

Please sign in to comment.