Skip to content

Commit

Permalink
<feature> improve font template and filter extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymousException committed Jun 17, 2024
1 parent 467818c commit 3893b12
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/font_style_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ init python early hide:
def my_load_face(fn, *args):
if renpy.game.preferences.language == "{tl_name}":
fn = "{font_path}"
renpy.config.rtl = {is_rtl_enabled}
return old_load_face(fn, *args)

renpy.text.font.load_face = my_load_face
renpy.config.rtl = {is_rtl_enabled}


translate {tl_name} python:
import os
Expand Down
10 changes: 5 additions & 5 deletions src/renpy_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def run(self):
log_print(msg)


def is_path_string(str):
if ' ' not in str and '.' in str:
if '\\' in str or '/' in str:
def is_path_or_dir_string(_string):
if ' ' not in _string and ':' not in _string and '[' not in _string and '{' not in _string:
if '\\' in _string or '/' in _string:
return True
return False

Expand Down Expand Up @@ -157,7 +157,7 @@ def ExtractFromFile(p, is_open_filter, filter_length, is_skip_underline, is_py2)
skip = True
# if not line_content.strip().startswith('text ') or line_content.strip().find(i) != 5:
# skip = True
if is_path_string(cmp_i):
if is_path_or_dir_string(cmp_i):
skip = True
if skip:
continue
Expand Down Expand Up @@ -199,7 +199,7 @@ def ExtractFromFile(p, is_open_filter, filter_length, is_skip_underline, is_py2)
skip = True
# if not line_content.strip().startswith('text ') or line_content.strip().find(i) != 5:
# skip = True
if is_path_string(cmp_i):
if is_path_or_dir_string(cmp_i):
skip = True
if skip:
continue
Expand Down
17 changes: 15 additions & 2 deletions src/renpy_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,24 @@ def GenGuiFontsOriginal(p, tl_name, font_path, is_rtl_enabled):
f = io.open(guiPath, 'r', encoding='utf-8')
_read = f.read()
f.close()
if (pythonBeginLine in _read):
if pythonBeginLine in _read:
appendMode = True
#result = ExtractStyleFontListFromDirectory(p)
if appendMode:
pass
f = io.open(guiPath, 'r', encoding='utf-8')
_lines = f.readlines()
f.close()
for idx,_line in enumerate(_lines):
if 'renpy.config.rtl' in _line:
index = _line.find('renpy.config.rtl')
_original = _line[index:]
_is_rtl_enabled = str(is_rtl_enabled)
_replaced = 'renpy.config.rtl = ' + _is_rtl_enabled + '\n'
_lines[idx] = _line.replace(_original, _replaced)
break
f = io.open(guiPath, 'w', encoding='utf-8')
f.writelines(_lines)
f.close()
else:
game_fonts_path = p + '/fonts/'
if os.path.exists(game_fonts_path) == False:
Expand Down

0 comments on commit 3893b12

Please sign in to comment.