Update the list of nerd font names when updating other unicode data as well

No longer need to store the list of names in our source code
This commit is contained in:
Kovid Goyal 2025-05-21 13:19:27 +05:30
parent 14043be919
commit ad03fa94b2
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 1746 additions and 12539 deletions

View file

@ -13,6 +13,6 @@ for attr in ('linguist-generated', 'linguist-vendored'):
fname = line.split(':', 1)[0] fname = line.split(':', 1)[0]
all_files.discard(fname) all_files.discard(fname)
all_files -= {'gen/nerd-fonts-glyphs.txt', 'gen/rowcolumn-diacritics.txt'} all_files -= {'gen/rowcolumn-diacritics.txt'}
cp = subprocess.run(['cloc', '--list-file', '-'], input='\n'.join(all_files).encode()) cp = subprocess.run(['cloc', '--list-file', '-'], input='\n'.join(all_files).encode())
raise SystemExit(cp.returncode) raise SystemExit(cp.returncode)

File diff suppressed because it is too large Load diff

View file

@ -43,8 +43,7 @@ if len(non_characters) != 66:
emoji_skin_tone_modifiers = frozenset(range(0x1f3fb, 0x1F3FF + 1)) emoji_skin_tone_modifiers = frozenset(range(0x1f3fb, 0x1F3FF + 1))
def get_data(fname: str, folder: str = 'UCD') -> Iterable[str]: def fetch_url(url: str) -> str:
url = f'https://www.unicode.org/Public/{folder}/latest/{fname}'
bn = os.path.basename(url) bn = os.path.basename(url)
local = os.path.join('/tmp', bn) local = os.path.join('/tmp', bn)
if os.path.exists(local): if os.path.exists(local):
@ -54,7 +53,12 @@ def get_data(fname: str, folder: str = 'UCD') -> Iterable[str]:
data = urlopen(url).read() data = urlopen(url).read()
with open(local, 'wb') as f: with open(local, 'wb') as f:
f.write(data) f.write(data)
for line in data.decode('utf-8').splitlines(): return data.decode()
def get_data(fname: str, folder: str = 'UCD') -> Iterable[str]:
url = f'https://www.unicode.org/Public/{folder}/latest/{fname}'
for line in fetch_url(url).splitlines():
line = line.strip() line = line.strip()
if line and not line.startswith('#'): if line and not line.startswith('#'):
yield line yield line
@ -151,13 +155,14 @@ def parse_ucd() -> None:
# the future. # the future.
marks.add(codepoint) marks.add(codepoint)
with open('gen/nerd-fonts-glyphs.txt') as f: gndata = fetch_url('https://raw.githubusercontent.com/ryanoasis/nerd-fonts/refs/heads/master/glyphnames.json')
for line in f: for name, val in json.loads(gndata).items():
line = line.strip() if name != 'METADATA':
if not line or line.startswith('#'): codepoint = int(val['code'], 16)
continue category, sep, name = name.rpartition('-')
code, category, name = line.split(' ', 2) name = name or category
codepoint = int(code, 16) name = name.replace('_', ' ')
print(11111111, name)
if name and codepoint not in name_map: if name and codepoint not in name_map:
name_map[codepoint] = name.upper() name_map[codepoint] = name.upper()
for word in name.lower().split(): for word in name.lower().split():

File diff suppressed because it is too large Load diff