"""Satellite Bash: troca a fonte Newyear Coffee (CC BY-ND 3.0, que nao permite versao modificada nem uso comercial aqui) pela League Gothic Regular (OFL 1.1, a mesma que o estudio usa em outros jogos). Uso: python3 -I swap-font.py """ import os import re import shutil import sys project, font, ofl = sys.argv[1:4] OLD = 'uid="uid://bbc8eg1men4bs" path="res://assets/third_party/fonts/newyear-coffee.regular.ttf"' NEW = 'path="res://assets/third_party/fonts/LeagueGothic-Regular.otf"' def edit(rel, fn): p = os.path.join(project, rel) s = open(p, encoding="utf-8").read() t = fn(s) assert t != s, rel open(p, "w", encoding="utf-8").write(t) fonts = os.path.join(project, "assets/third_party/fonts") for f in os.listdir(fonts): if f.startswith("newyear-coffee"): os.remove(os.path.join(fonts, f)) shutil.copyfile(font, os.path.join(fonts, "LeagueGothic-Regular.otf")) edit("source/themes/ui_theme.tres", lambda s: s.replace(OLD, NEW)) edit("source/scenes/main_menu.tscn", lambda s: s.replace(OLD, NEW)) edit( "source/scenes/credits.tscn", lambda s: s.replace( '"\\"Newyear Coffee Regular\\" by Khurasan\nlicensed under CC BY-ND 3.0"', '"\\"League Gothic Regular\\" by The League of Moveable Type\nlicensed under OFL 1.1"', ).replace( "https://www.1001fonts.com/newyear-coffee-font.html", "https://www.1001fonts.com/league-gothic-font.html", ), ) # Texto da OFL (o LICENSE-OFL.md do estudio, sem a marcacao markdown), para a tela de licencas. text = open(ofl, encoding="utf-8").read() text = text.replace(" ", "").replace("\\-", "-") text = re.sub(r"^#+ ", "", text, flags=re.M) text = re.sub(r"\n{3,}", "\n\n", text).strip() text = "League Gothic, Copyright 2009 - 2011, The League of Moveable Type (http://theleagueofmoveabletype.com).\nThis Font Software is licensed under the SIL Open Font License, Version 1.1.\n\n" + text esc = text.replace("\\", "\\\\").replace('"', '\\"') def licenses(s): a = s.index('[node name="CCByND3_0LicenseContainer"') b = s.index('[node name="GodotLicenseContainer"') blk = s[a:b] blk = blk.replace("CCByND3_0LicenseContainer", "OFLLicenseContainer") blk = blk.replace('text = "CC BY-ND 3.0"', 'text = "SIL OFL 1.1"') blk = re.sub(r'(LicenseTextLabel.*?\ntext = )"(?:[^"\\]|\\.)*"', lambda m: m.group(1) + '"' + esc + '"', blk, flags=re.S) return s[:a] + blk + s[b:] edit("source/scenes/licenses.tscn", licenses) os.remove(os.path.join(project, "..", "LICENSE-CC-BY-ND-3.0"))