*/}}
1
0

la_icon_gen.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import fontforge
  2. import unicodedata
  3. gen=open("la_icon.h", "w")
  4. written=0;
  5. no_name=[]
  6. categories=[]
  7. f=[]
  8. gen.write("#pragma once\n\n")
  9. def find_glyph(unicode):
  10. glyph=None
  11. for i in range(len(f)):
  12. try:
  13. glyph=f[i][unicode]
  14. except:
  15. glyph=None
  16. if glyph:
  17. break
  18. return glyph
  19. groups=[
  20. [73, "currency", []],#Currency Symbols]
  21. [77, "arrows", []],#Arrows]
  22. [78, "dingbats", []],#Mathematical Operators]
  23. [79, "tech", []],#Miscellaneous Technical]
  24. #[83, "box", []],#Box Drawing]
  25. #[84, "block", []],#Block Elements]
  26. [85, "geom", []],#Geometric Shapes]
  27. [86, "misc", []],#Miscellaneous Symbols]
  28. [87, "dingbats", []],#Dingbats]
  29. [88, "math", []],#Miscellaneous Mathematical Symbols-A]
  30. [89, "arrows", []],#Supplemental Arrows-A]
  31. [90, "braille", []],#Braille Patterns]
  32. [91, "arrows", []],#Supplemental Arrows-B]
  33. [92, "math", []],#Miscellaneous Mathematical Symbols-B]
  34. [93, "math", []],#Supplemental Mathematical Operators]
  35. [94, "misc", []],#Miscellaneous Symbols and Arrows]
  36. #[163, "linear_b_s", []],#Linear B Syllabary]
  37. #[164, "linear_b_i", []],#Linear B Ideograms]
  38. #[238,, []],# Cuneiform]
  39. #[239,, []],# Cuneiform Numbers and Punctuation]
  40. #[240, "edc", []],#Early Dynastic Cuneiform]
  41. [241, "egyptian", []],#Egyptian Hieroglyphs]
  42. #[242,, []],# Egyptian Hieroglyph Format Controls]
  43. #[243, "anatonllian", []],#Anatolian Hieroglyphs]
  44. #[244, "bamum", []],#Bamum Supplement]
  45. #[257, "duployan", []],#Duployan]
  46. [259, "musical", []],#Byzantine Musical Symbols]
  47. [260, "musical", []],#Musical Symbols]
  48. [261, "musical", []],#Ancient Greek Musical Notation]
  49. [262, "mayan_num", []],#Mayan Numerals]
  50. [263, "taixuan", []],#Tai Xuan Jing Symbols]
  51. [264, "rod", []],#Counting Rod Numerals]
  52. #[274, "arabic_math", []],#Arabic Mathematical Alphabetic Symbols]
  53. #[275,, []],# Mahjong Tiles]
  54. #[276,, []],# Domino Tiles]
  55. #[277,, []],# Playing Cards]
  56. [278, "enclosed", []],#Enclosed Alphanumeric Supplement]
  57. [279, "enclosed", []],#Enclosed Ideographic Supplement]
  58. [280, "misc", []],#Miscellaneous Symbols and Pictographs]
  59. [281, "emo", []],#Emoticons]
  60. [282, "dingbats", []],#Ornamental Dingbats]
  61. [283, "transport", []],#Transport and Map Symbols]
  62. [284, "alchemical", []],#Alchemical Symbols]
  63. [285, "geom", []],#Geometric Shapes Extended]
  64. [286, "arrows", []],#Supplemental Arrows-C]
  65. [287, "pic", []],#Supplemental Symbols and Pictographs]
  66. [288, "chess", []],#Chess Symbols]
  67. [289, "pic", []],#Symbols and Pictographs Extended-A]
  68. #[290, "", []],#legact computing]
  69. ]
  70. f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoSansSymbols-Regular.ttf"))
  71. f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoSansSymbols2-Regular.ttf"))
  72. f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoEmoji-Regular.ttf"))
  73. f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoMusic-Regular.ttf"))
  74. f.append(fontforge.open("/home/yiming/.local/share/fonts/NotoSansEgyptianHieroglyphs-Regular.ttf"))
  75. for i in range(len(groups)):
  76. begin=fontforge.UnicodeBlockStartFromLib(groups[i][0])
  77. end=fontforge.UnicodeBlockEndFromLib(groups[i][0])+1
  78. for c in range(begin,end):
  79. glyph=find_glyph(c)
  80. if glyph is not None:
  81. groups[i][2].append(glyph)
  82. for i in range(len(groups)):
  83. for j in range(i+1,len(groups)):
  84. if groups[j][1]!=groups[i][1] or len(groups[j][2])==0:
  85. continue;
  86. groups[i][2].extend(groups[j][2])
  87. groups[j][2]=[]
  88. irow=0;
  89. row=40;
  90. for i in range(len(groups)):
  91. irow=0;
  92. if len(groups[i][2])==0:
  93. continue;
  94. gen.write("// "+groups[i][1]+"\n#ifndef _LA_ICO_"+groups[i][1].upper()+"\n#define _LA_ICO_"+groups[i][1].upper()+"\\\n")
  95. for c in groups[i][2]:
  96. if (irow%row==0):
  97. gen.write("\"")
  98. gen.write(str(chr(c.unicode)));
  99. written+=1;
  100. irow+=1
  101. if (irow%row==0):
  102. gen.write("\"\\\n")
  103. if (irow%row!=0):
  104. gen.write("\"\n")
  105. gen.write(";\n#endif\n\n")
  106. gen.write("// Generated %s characters\n"%(written));
  107. gen.write("// Glyphs with no names: %d\n// "%len(no_name));
  108. for n in no_name:
  109. gen.write(chr(n));
  110. gen.close()