mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Copy in systemwide NERD font during build
Means it works when running from source and can be used as the source for copying the font into built packages
This commit is contained in:
35
setup.py
35
setup.py
@@ -837,7 +837,7 @@ def parallel_run(items: List[Command]) -> None:
|
||||
if verbose:
|
||||
print(' '.join(compile_cmd.cmd))
|
||||
elif isatty:
|
||||
print(f'\r\x1b[K[{num}/{total}] {compile_cmd.desc}', end='')
|
||||
print(f'\r\x1b[K[{num}/{total}] {compile_cmd.desc}', end='') # ]]
|
||||
else:
|
||||
print(f'[{num}/{total}] {compile_cmd.desc}', flush=True)
|
||||
printed = True
|
||||
@@ -853,6 +853,38 @@ def parallel_run(items: List[Command]) -> None:
|
||||
run_tool(list(failed.cmd))
|
||||
|
||||
|
||||
def add_builtin_fonts(args: Options) -> None:
|
||||
fonts_dir = os.path.join(src_base, 'fonts')
|
||||
os.makedirs(fonts_dir, exist_ok=True)
|
||||
|
||||
for psname, (filename, human_name) in {
|
||||
'SymbolsNFM': ('SymbolsNerdFontMono-Regular.ttf', 'Symbols NERD Font Mono')
|
||||
}.items():
|
||||
dest = os.path.join(fonts_dir, filename)
|
||||
if os.path.exists(dest):
|
||||
continue
|
||||
font_file = ''
|
||||
if is_macos:
|
||||
for candidate in (os.path.expanduser('~/Library/Fonts'), '/Library/Fonts', '/System/Library/Fonts', '/Network/Library/Fonts'):
|
||||
q = os.path.join(candidate, filename)
|
||||
if os.path.exists(q):
|
||||
font_file = q
|
||||
break
|
||||
else:
|
||||
lines = subprocess.check_output([
|
||||
'fc-match', '--format', '%{file}\n%{postscriptname}', f'term:postscriptname={psname}', 'file', 'postscriptname']).decode().splitlines()
|
||||
if len(lines) != 2:
|
||||
raise SystemExit(f'fc-match returned unexpected output: {lines}')
|
||||
if lines[1] != psname:
|
||||
raise SystemExit(f'The font {human_name!r} was not found on your system, please install it')
|
||||
font_file = lines[0]
|
||||
if not font_file:
|
||||
raise SystemExit(f'The font {human_name!r} was not found on your system, please install it')
|
||||
print(f'Copying {human_name!r} from {font_file}')
|
||||
shutil.copy(font_file, dest)
|
||||
os.chmod(dest, 0o644)
|
||||
|
||||
|
||||
def compile_c_extension(
|
||||
kenv: Env,
|
||||
module: str,
|
||||
@@ -1093,6 +1125,7 @@ def build(args: Options, native_optimizations: bool = True, call_init: bool = Tr
|
||||
)
|
||||
compile_glfw(args.compilation_database, args.build_dsym)
|
||||
compile_kittens(args)
|
||||
add_builtin_fonts(args)
|
||||
|
||||
|
||||
def safe_makedirs(path: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user