mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
generate-glyph-info: Fix double entries
[why] Two glyphs may not have the same name (normally). Our glyphnames.json will break. [how] Do not add two entries with the same name but rather report the codepoints in the bottom. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
6932ff2d8f
commit
2fa45981ee
2 changed files with 18 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# coding=utf8
|
# coding=utf8
|
||||||
# Nerd Fonts Version: 3.1.1
|
# Nerd Fonts Version: 3.1.1
|
||||||
# Script Version: 1.1.1
|
# Script Version: 1.2.0
|
||||||
|
|
||||||
# Example Usage:
|
# Example Usage:
|
||||||
# ./generate-glyph-info-from-set.py --font ../../src/glyphs/materialdesignicons-webfont.ttf --start f001 --end f847 --offset 4ff --prefix mdi
|
# ./generate-glyph-info-from-set.py --font ../../src/glyphs/materialdesignicons-webfont.ttf --start f001 --end f847 --offset 4ff --prefix mdi
|
||||||
|
@ -66,9 +66,13 @@ elif args.symbolOffset:
|
||||||
signedOffset = int(sign+'0x'+format(offset, 'X'), 16)
|
signedOffset = int(sign+'0x'+format(offset, 'X'), 16)
|
||||||
hexPosition = args.symbolFontStart + signedOffset
|
hexPosition = args.symbolFontStart + signedOffset
|
||||||
|
|
||||||
symbolFont.selection.select((str("ranges"),str("unicode")),args.symbolFontStart,args.symbolFontEnd)
|
allNames = {}
|
||||||
|
suppressedEntries = []
|
||||||
for index, sym_glyph in enumerate(symbolFont.selection.byGlyphs):
|
symbolFont.encoding = 'UnicodeFull'
|
||||||
|
for index in range(args.symbolFontStart, args.symbolFontEnd + 1):
|
||||||
|
if not index in symbolFont:
|
||||||
|
continue
|
||||||
|
sym_glyph = symbolFont[index]
|
||||||
slot = format(sym_glyph.unicode, 'X')
|
slot = format(sym_glyph.unicode, 'X')
|
||||||
name = sym_glyph.glyphname
|
name = sym_glyph.glyphname
|
||||||
sh_name = "i_" + args.prefix + "_" + name.replace("-", "_")
|
sh_name = "i_" + args.prefix + "_" + name.replace("-", "_")
|
||||||
|
@ -78,9 +82,18 @@ for index, sym_glyph in enumerate(symbolFont.selection.byGlyphs):
|
||||||
else:
|
else:
|
||||||
char = chr(int('0x'+slot, 16) + signedOffset)
|
char = chr(int('0x'+slot, 16) + signedOffset)
|
||||||
|
|
||||||
print("i='" + char + "' " + sh_name + "=$i")
|
entryString = "i='" + char + "' " + sh_name + "=$i SLOT " + slot + ' ' + str(index)
|
||||||
|
if name not in allNames:
|
||||||
|
print(entryString)
|
||||||
|
else:
|
||||||
|
suppressedEntries.append(entryString)
|
||||||
|
|
||||||
ctr += 1
|
ctr += 1
|
||||||
hexPosition += 1
|
hexPosition += 1
|
||||||
|
allNames[name] = 1
|
||||||
|
|
||||||
print("Done, generated " + str(ctr) + " glyphs")
|
print("Done, generated " + str(ctr) + " glyphs")
|
||||||
|
|
||||||
|
if len(suppressedEntries) > 0:
|
||||||
|
print('FOLLOGING ENTRIES SUPPRESSED to prevent double names with different codepoints:')
|
||||||
|
print('\n'.join(suppressedEntries))
|
||||||
|
|
|
@ -151,7 +151,6 @@ i='' i_cod_folder_opened=$i
|
||||||
i='' i_cod_gear=$i
|
i='' i_cod_gear=$i
|
||||||
i='' i_cod_gift=$i
|
i='' i_cod_gift=$i
|
||||||
i='' i_cod_gist_secret=$i
|
i='' i_cod_gist_secret=$i
|
||||||
i='' i_cod_file_code=$i
|
|
||||||
i='' i_cod_git_commit=$i
|
i='' i_cod_git_commit=$i
|
||||||
i='' i_cod_git_compare=$i
|
i='' i_cod_git_compare=$i
|
||||||
i='' i_cod_git_merge=$i
|
i='' i_cod_git_merge=$i
|
||||||
|
|
Loading…
Reference in a new issue