From 0e0cb373c03765fc41ad8e905818a83d4f6565a8 Mon Sep 17 00:00:00 2001 From: Jonathan Gamble Date: Sat, 16 Nov 2024 10:29:16 -0600 Subject: [PATCH] enforce incremental sequence numbers in lichess.sfd --- bin/gen/licon.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/gen/licon.py b/bin/gen/licon.py index 1c227617b503..f7abc53f2a7a 100755 --- a/bin/gen/licon.py +++ b/bin/gen/licon.py @@ -114,19 +114,28 @@ def parse_codes(): unnamed_re = re.compile(r'$|uni[a-f0-9]{4}', re.IGNORECASE) codes = {} warnings = [] + corrected = [] with open('lichess.sfd', 'r') as f: lines = f.readlines() name = None + n = 0 + line_ok = True for line in lines: if line.startswith('StartChar:'): name = dash_camel(line.split(': ')[1].strip()) elif line.startswith('Encoding:') and name is not None: code_point = int(line.split(' ')[1]) if code_point >= 0xe000 and code_point <= 0xefff: + code_point = 57344 + n + n += 1 + line = f'Encoding: {code_point} {code_point} {n}\n' if unnamed_re.match(name): warnings.append(f' Unnamed glyph "{name}" at code point {code_point}\n') - continue - codes[name] = code_point + else: + codes[name] = code_point + corrected.append(line) + with open('lichess.sfd', 'w') as f: + f.write(''.join(corrected)) print('' if not warnings else f'\nWarnings:\n{"".join(warnings)}') return dict(sorted(codes.items(), key=lambda x: x[1]))