123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- import fontforge
- import unicodedata
- gen=open("la_icon.h", "w")
- written=0;
- no_name=[]
- categories=[]
- f=[]
- gen.write("#pragma once\n\n")
- def find_glyph(unicode):
- glyph=None
- for i in range(len(f)):
- try:
- glyph=f[i][unicode]
- except:
- glyph=None
- if glyph:
- break
- return glyph
- groups=[
- [73, "currency", []],
- [77, "arrows", []],
- [78, "dingbats", []],
- [79, "tech", []],
- [85, "geom", []],
- [86, "misc", []],
- [87, "dingbats", []],
- [88, "math", []],
- [89, "arrows", []],
- [90, "braille", []],
- [91, "arrows", []],
- [92, "math", []],
- [93, "math", []],
- [94, "misc", []],
- [241, "egyptian", []],
- [259, "musical", []],
- [260, "musical", []],
- [261, "musical", []],
- [262, "mayan_num", []],
- [263, "taixuan", []],
- [264, "rod", []],
- [278, "enclosed", []],
- [279, "enclosed", []],
- [280, "misc", []],
- [281, "emo", []],
- [282, "dingbats", []],
- [283, "transport", []],
- [284, "alchemical", []],
- [285, "geom", []],
- [286, "arrows", []],
- [287, "pic", []],
- [288, "chess", []],
- [289, "pic", []],
- ]
- f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoSansSymbols-Regular.ttf"))
- f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoSansSymbols2-Regular.ttf"))
- f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoEmoji-Regular.ttf"))
- f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoMusic-Regular.ttf"))
- f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoSansEgyptianHieroglyphs-Regular.ttf"))
- for i in range(len(groups)):
- begin=fontforge.UnicodeBlockStartFromLib(groups[i][0])
- end=fontforge.UnicodeBlockEndFromLib(groups[i][0])+1
- for c in range(begin,end):
- glyph=find_glyph(c)
- if glyph is not None:
- groups[i][2].append(glyph)
- for i in range(len(groups)):
- for j in range(i+1,len(groups)):
- if groups[j][1]!=groups[i][1] or len(groups[j][2])==0:
- continue;
- groups[i][2].extend(groups[j][2])
- groups[j][2]=[]
- irow=0;
- row=40;
- for i in range(len(groups)):
- irow=0;
- if len(groups[i][2])==0:
- continue;
- gen.write("// "+groups[i][1]+"\n#ifndef _LA_ICO_"+groups[i][1].upper()+"\n#define _LA_ICO_"+groups[i][1].upper()+"\\\n")
- for c in groups[i][2]:
- if (irow%row==0):
- gen.write("\"")
- gen.write(str(chr(c.unicode)));
- written+=1;
- irow+=1
- if (irow%row==0):
- gen.write("\"\\\n")
- if (irow%row!=0):
- gen.write("\"\n")
- gen.write(";\n#endif\n\n")
- gen.write("// Generated %s characters\n"%(written));
- gen.write("// Glyphs with no names: %d\n// "%len(no_name));
- for n in no_name:
- gen.write(chr(n));
- gen.close()
|