Restore Cyrillic rendering in the Linux installer with Xft

This commit is contained in:
lcd1232 committed 2026-10-31 17:40:54 +04:00
1 parent 7d62cbfa85
commit d0e27b95c4
5 files changed
+66 -9

No files matched your search

+1
View File
@@ -64,6 +64,7 @@ These tools run on the developer's or player's machine during the build. They ar
| Component | Source | License | Where in the release |
|---|---|---|---|
| Tcl/Tk 9.0.4, rebuilt with Xft for the Linux installer | https://github.com/tcltk/tcl and https://github.com/tcltk/tk, tag `core-9-0-4`; archives pinned by SHA-256 in `tools/make_release_linux.py` | Tcl/Tk licence (BSD-style) | `python/lib/`; licence texts in `licenses/tcl-license.terms` and `licenses/tk-license.terms` |
| CPython 3.14.9 embeddable package, with `tkinter` and Tcl/Tk 9.0.4 taken from the python.org 3.14.9 installer's component MSI (unpacked, never run); includes `vcruntime140*.dll` (Microsoft, redistributable with Python), OpenSSL, libffi, SQLite, zlib, libtommath | https://www.python.org/downloads/release/python-3149/ | PSF-2.0 (Tcl/Tk: Tcl/Tk licence, BSD-style) | `python/` |
| numpy 2.5.4 (with its bundled OpenBLAS), lz4 4.4.5, cryptography 50.0.2 (with its bundled OpenSSL), cffi 2.1.1, pycparser 3.11 | PyPI binary wheels, pins in `tools/requirements-installer.txt` | BSD-3-Clause; lz4 BSD-3-Clause; cryptography Apache-2.0 OR BSD-3-Clause; cffi MIT; pycparser BSD-3-Clause | `python/Lib/site-packages/` |
| llvm-mingw 20261020 (LLVM/Clang/LLD 23, mingw-w64, libc++, libunwind, compiler-rt), x86_64 subset | https://github.com/mstorsjo/llvm-mingw/releases/tag/20261020 | Apache-2.0 with LLVM exception; mingw-w64 ZPL-2.1/BSD/public domain; libc++ and libunwind Apache-2.0 with LLVM exception and MIT/UIUC; winpthreads MIT | `llvm/` |
+2 -1
View File
@@ -113,7 +113,8 @@ totk.ini.example, VERSION the default ini; the release string (the repository's
`tools/make_release_linux.py` builds the same setup for Linux and packs it as `TotK-Setup-x86_64.AppImage` (the static
type-2 runtime: no libfuse2 needed on the host). The player makes it executable and starts it; on a Steam Deck, from
Desktop Mode. The setup builds the game into the folder they pick, as on Windows, and the game is `totk` there with
Desktop Mode. Building the release also needs `make` and `pkg-config`. The bundled Tcl/Tk 9.0.4 is rebuilt with
Xft against the sniper sysroot so Russian text uses system TrueType fonts. The setup builds the game into the folder they pick, as on Windows, and the game is `totk` there with
`libSDL3.so.0` beside it. The folder inside the AppImage:
```
+5 -4
View File
@@ -66,8 +66,9 @@ class App:
self.icon = tk.PhotoImage(file=str(png))
root.iconphoto(True, self.icon)
root.protocol('WM_DELETE_WINDOW', self.on_close)
self.ui_font = 'Segoe UI' if os.name == 'nt' else 'DejaVu Sans'
style = ttk.Style(root)
style.configure('Title.TLabel', font=('Segoe UI', 15, 'bold'))
style.configure('Title.TLabel', font=(self.ui_font, 15, 'bold'))
style.configure('Notice.TLabel', background='#fff3cd', foreground='#664d03', padding=8)
style.configure('Err.TLabel', foreground='#c01c28')
style.configure('Version.TLabel', foreground='#808080')
@@ -219,7 +220,7 @@ class App:
self.cancel_button.pack(side='right')
self.log_toggle = self.button(bar, 'ui.show_log', self.toggle_log)
self.log_toggle.pack(side='left')
self.run_header = ttk.Label(f, font=('Segoe UI', 11, 'bold'))
self.run_header = ttk.Label(f, font=(self.ui_font, 11, 'bold'))
self.run_header.pack(anchor='w')
self.step_rows = {}
self.steps_box = ttk.Frame(f)
@@ -233,7 +234,7 @@ class App:
self.warn_label = ttk.Label(f, wraplength=620, justify='left', foreground='#9a6700')
self.warn_label.pack(anchor='w')
self.log_frame = ttk.Frame(f)
self.log = tk.Text(self.log_frame, height=10, wrap='word', state='disabled', font=('Consolas', 9))
self.log = tk.Text(self.log_frame, height=10, wrap='word', state='disabled', font=('Consolas' if os.name == 'nt' else 'DejaVu Sans Mono', 9))
scroll = ttk.Scrollbar(self.log_frame, command=self.log.yview)
self.log.configure(yscrollcommand=scroll.set)
scroll.pack(side='right', fill='y')
@@ -378,7 +379,7 @@ class App:
glyph.configure(text=GLYPH[state], foreground=COLOR[state])
name.configure(text=self.cat('step.' + s) + (f' ({self.cat("ui.state_" + state)})'
if state in (SKIPPED, FAILED) else ''),
font=('Segoe UI', 10, 'bold') if state == RUNNING else ('Segoe UI', 10))
font=(self.ui_font, 10, 'bold') if state == RUNNING else ('Segoe UI', 10))
mode = m.mode or 'install'
self.run_header.configure(text=self.cat('ui.running_' + mode if mode in ('install', 'resume', 'update')
else 'ui.running_install'))
+2
View File
@@ -122,6 +122,8 @@ def fetch(name):
url, want = PINS[name]
DL.mkdir(parents=True, exist_ok=True)
path = DL / Path(url.split('?')[0]).name.replace('%7E', '~')
if name in ('tcl-linux-src', 'tk-linux-src'):
path = DL / f'{name}-9.0.4.tar.gz' # upstream archives have identical basenames
if name == 'libvpx-src':
path = DL / 'libvpx-1.17.0.tar.gz'
if not path.is_file():
+56 -4
View File
@@ -61,6 +61,10 @@ PINS = {
'python-linux': ('https://github.com/astral-sh/python-build-standalone/releases/download/20261026/'
'cpython-3.14.10%2B20261026-x86_64-unknown-linux-gnu-install_only.tar.gz',
'1b38024924eb7f4cf0cab45d7b871d1f1991354190fccd2625ac7529a43786e2'),
'tcl-linux-src': ('https://github.com/tcltk/tcl/archive/refs/tags/core-9-0-4.tar.gz',
'8c01bac92a9a8ce271b63d3aa28f09cde2c6762d6719ca671cdc8aee25391234'),
'tk-linux-src': ('https://github.com/tcltk/tk/archive/refs/tags/core-9-0-4.tar.gz',
'ab9bd89fcff2e1248b7a9c097035f817fa0725285028c95686fdb92db65bc148'),
'ninja-linux': ('https://github.com/ninja-build/ninja/releases/download/v1.13.2/ninja-linux.zip',
'5749cbc4e668273514150a80e387a957f933c6ed3f5f11e03fb30955e2bbead6'),
'zstd-src': ('https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz',
@@ -81,7 +85,7 @@ mr.PINS.update(PINS) # one cache (toolchain/release-dl) and one fetch for both
LLVM_MEMBERS = [f'bin/clang-{LLVM_MAJOR}', 'bin/clang', 'bin/clang++', 'bin/lld', 'bin/ld.lld', 'bin/llvm-ar',
'bin/llvm-ranlib', 'bin/llvm-objcopy', 'bin/llvm-strip', f'lib/clang/{LLVM_MAJOR}/include']
# The parts of the sniper SDK a C/C++ compile and link for x86_64 can read.
SNIPER_MEMBERS = ['usr/include', 'usr/lib/x86_64-linux-gnu', 'usr/lib/gcc/x86_64-linux-gnu',
SNIPER_MEMBERS = ['usr/include', 'usr/share/pkgconfig', 'usr/lib/x86_64-linux-gnu', 'usr/lib/gcc/x86_64-linux-gnu',
'lib/x86_64-linux-gnu', 'lib64', 'usr/share/doc/libsdl3-0', 'usr/share/doc/libopus0',
'usr/share/doc/libvpx6', 'usr/share/doc/libc6', 'usr/share/doc/gcc-10-base',
'usr/share/doc/libvulkan1']
@@ -139,8 +143,10 @@ def full_sysroot():
"""The sniper SDK's x86_64 compile and link files in toolchain/release-work/sniper, absolute symlinks made relative
(the SDK points some at /lib and /usr/lib, which outside its container are the host's)."""
root = WORK / 'sniper'
if (root / '.relinked').is_file():
if (root / '.relinked').is_file() and (root / 'usr/share/pkgconfig/xproto.pc').is_file():
return root
# Older cached SDK extractions omitted the font libraries' architecture-independent pkg-config files.
(root / '.unpacked').unlink(missing_ok=True)
tar_extract('sniper-sdk', root, SNIPER_MEMBERS)
for p in root.rglob('*'):
if p.is_symlink() and os.readlink(p).startswith('/'):
@@ -309,7 +315,44 @@ def build_sysroot(out, sysroot, files):
# ---- python/ ---------------------------------------------------------------------------------------------------------
def build_python(out):
def build_tk_xft(out, llvm, sysroot):
"""Replace standalone Python's no-Xft Tcl/Tk with the same version using system TrueType fonts (#227)."""
prefix = WORK / 'tcltk-xft'
env = dict(os.environ, CC=sysroot_cc(llvm, sysroot),
PKG_CONFIG_SYSROOT_DIR=str(sysroot),
PKG_CONFIG_LIBDIR=os.pathsep.join(str(sysroot / p) for p in
('usr/lib/x86_64-linux-gnu/pkgconfig', 'usr/share/pkgconfig')),
PKG_CONFIG_PATH='')
sources = {}
for name in ('tcl', 'tk'):
src = mr.unpack(f'{name}-linux-src') / f'{name}-core-9-0-4'
sources[name] = src
build = src / 'unix'
options = [f'--prefix={prefix}', '--enable-shared', '--disable-zipfs', '--disable-rpath']
if name == 'tk':
options += [f'--with-tcl={prefix / "lib"}', '--enable-xft', '--disable-libcups', '--disable-xss']
run([build / 'configure', *options], cwd=build, env=env)
run(['make', f'-j{os.cpu_count() or 4}'], cwd=build, env=env)
run(['make', 'install'], cwd=build, env=env)
lib = prefix / 'lib'
# A successful GUI selftest alone did not catch missing glyphs. Reject a no-Xft build before packaging it.
symbols = subprocess.run(['nm', '-D', str(lib / 'libtcl9tk9.0.so')],
capture_output=True, text=True, check=True).stdout
if not re.search(r'\bU Xft', symbols):
sys.exit('Tcl/Tk build has no Xft font rendering')
dst = out / 'python' / 'lib'
for name in ('libtcl9.0.so', 'libtcl9tk9.0.so'):
shutil.copy2(lib / name, dst / name)
for name in ('tcl9.0', 'tk9.0'):
shutil.rmtree(dst / name)
shutil.copytree(lib / name, dst / name, symlinks=True)
licenses = out / 'licenses'
licenses.mkdir(exist_ok=True)
for name, src in sources.items():
shutil.copy2(src / 'license.terms', licenses / f'{name}-license.terms')
def build_python(out, llvm, sysroot):
src = mr.unpack('python-linux') / 'python'
py = out / 'python'
shutil.copytree(src, py, symlinks=True,
@@ -319,6 +362,7 @@ def build_python(out):
run([exe, '-m', 'pip', 'install', '--no-compile', '--only-binary', ':all:', '-r',
ROOT / 'tools' / 'requirements-installer.txt'], env=env, stdout=subprocess.DEVNULL)
run([exe, '-m', 'pip', 'uninstall', '-y', 'pip'], stdout=subprocess.DEVNULL) # the setup installs nothing
build_tk_xft(out, llvm, sysroot)
strip(py, out / 'llvm' / 'bin' / 'llvm-strip')
site = next(py.glob('lib/python3.*/site-packages'))
# The release folder, tools/ and recomp/ on sys.path, as the Windows python's ._pth does: `python -m installer` and
@@ -370,6 +414,8 @@ APPRUN = '''#!/bin/sh
# The AppImage entry: the setup window, run by the bundled Python from the read-only mount (no bytecode written there).
HERE="$(dirname "$(readlink -f "$0")")"
export PYTHONDONTWRITEBYTECODE=1
export TCL_LIBRARY="$HERE/python/lib/tcl9.0"
export TK_LIBRARY="$HERE/python/lib/tk9.0"
exec "$HERE/python/bin/python3" -m installer.gui "$@"
'''
@@ -452,6 +498,12 @@ def check_bundle(out):
f'{r.stderr[-2000:]}')
print(f'bundle check: the installer ran the host check from the folder and stopped at the game files '
f'(exit {r.returncode})')
run([py, '-c', 'import tkinter as tk; from tkinter import font; '
'root = tk.Tk(); root.withdraw(); '
'fonts = [font.nametofont("TkDefaultFont"), font.Font(family="DejaVu Sans"), '
'font.Font(family="DejaVu Sans Mono")]; '
'missing = [(f.actual("family"), c) for f in fonts for c in "УстановкаЁёЙй" if f.measure(c) <= 0]; '
'root.destroy(); assert not missing, f"Cyrillic glyphs missing: {missing}"'], cwd='/', env=env)
r = subprocess.run([str(py), '-m', 'installer.gui', '--selftest', '--root', str(out)], cwd='/', env=env,
capture_output=True, text=True, timeout=300)
if r.returncode:
@@ -511,7 +563,7 @@ def main():
build_bin(out, llvm, sysroot)
rtlib = runtime_lib(out, llvm, sysroot)
build_sysroot(out, sysroot, used_sysroot_files(out, llvm, sysroot, rtlib))
build_python(out)
build_python(out, llvm, sysroot)
mr.build_sources(out)
collect_licenses(out, sysroot)
build_entry(out)