1
Fork 0

Write a script to output kitty codepoints

This should fix all font issues forever
This commit is contained in:
Hadeed 2023-09-27 08:15:43 +05:00
parent f6403a5554
commit 4dca9dd491
3 changed files with 42 additions and 8 deletions

40
bin/write_symbol_map.py Executable file
View file

@ -0,0 +1,40 @@
#! /usr/bin/env python3
import os
import subprocess
import sys
font_file = "/usr/share/fonts/TTF/SymbolsNerdFontMono-Regular.ttf"
if not os.path.exists(font_file):
sys.stderr.write(f"Error: The font file does not exist.\n")
sys.exit(1)
def create_maps(numbers):
start = numbers[0]
end = start
maps = []
for number in numbers[1:]:
if number == end + 1:
end = number
else:
codepoints = f"U+{start:X}" if start == end else f"U+{start:X}-U+{end:X}"
maps.append(f"symbol_map {codepoints} Symbols Nerd Font Mono")
start = end = number
codepoints = f"U+{start:X}" if start == end else f"U+{start:X}-U+{end:X}"
maps.append(f"symbol_map {codepoints} Symbols Nerd Font Mono")
return maps
output = subprocess.check_output(f"otfinfo -u {font_file} | cut -c4-7", shell=True, text=True)
numbers = [int(line.strip(), 16) for line in output.strip().split('\n')]
maps = create_maps(numbers)
symbol_map_file = os.path.join(os.getenv("HOME"), ".config", "kitty", "symbol_map.conf")
with open(symbol_map_file, "w") as file:
for map in maps:
file.write(f"{map}\n")
print("Symbol map written successfully!")

View file

@ -1,18 +1,11 @@
bat
bear
ccls
exa
fd
kitty
neovim
python-pillow
python-pygments
qmk
ripgrep
starship
ttf-jetbrains-mono
ttf-nerd-fonts-symbols
unclutter
ttf-nerd-fonts-symbols-mono
xclip
zola
zsh

View file

@ -11,4 +11,5 @@ tab_bar_style hidden
hide_window_decorations yes
include keys.conf
include symbol_map.conf
include themes/gruvbox.conf