*/}}

la_icon_gen.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. import fontforge
  2. import unicodedata
  3. import re
  4. gen=open("la_icon.h", "w")
  5. written=0;
  6. no_name=[]
  7. categories=[]
  8. f=[]
  9. gen.write("#pragma once\n\n")
  10. def find_glyph(unicode):
  11. glyph=None
  12. for i in range(len(f)):
  13. try:
  14. glyph=f[i][unicode]
  15. except:
  16. glyph=None
  17. if glyph:
  18. break
  19. return glyph
  20. def uniblock(ch):
  21. #assert isinstance(ch, unicode) and len(ch) == 1, repr(ch)
  22. for i, block in enumerate(_blocks):
  23. if block[0] <= ch <= block[1]:
  24. return i
  25. return None
  26. def _initBlocks(text):
  27. global _blocks
  28. _blocks = []
  29. import re
  30. pattern = re.compile(r'([0-9A-F]+)\.\.([0-9A-F]+);\ (\S.*\S)')
  31. for line in text.splitlines():
  32. m = pattern.match(line)
  33. if m:
  34. start, end, name = m.groups()
  35. _blocks.append([int(start, 16), int(end, 16), name, []])
  36. # retrieved from http://unicode.org/Public/UNIDATA/Blocks.txt
  37. _initBlocks('''# Blocks-16.0.0.txt
  38. # Date: 2024-02-02
  39. # © 2024 Unicode®, Inc.
  40. # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
  41. # For terms of use and license, see https://www.unicode.org/terms_of_use.html
  42. #
  43. # Unicode Character Database
  44. # For documentation, see https://www.unicode.org/reports/tr44/
  45. #
  46. # Format:
  47. # Start Code..End Code; Block Name
  48. # ================================================
  49. # Note: When comparing block names, casing, whitespace, hyphens,
  50. # and underbars are ignored.
  51. # For example, "Latin Extended-A" and "latin extended a" are equivalent.
  52. # For more information on the comparison of property values,
  53. # see UAX #44: https://www.unicode.org/reports/tr44/
  54. #
  55. # All block ranges start with a value where (cp MOD 16) = 0,
  56. # and end with a value where (cp MOD 16) = 15. In other words,
  57. # the last hexadecimal digit of the start of range is ...0
  58. # and the last hexadecimal digit of the end of range is ...F.
  59. # This constraint on block ranges guarantees that allocations
  60. # are done in terms of whole columns, and that code chart display
  61. # never involves splitting columns in the charts.
  62. #
  63. # All code points not explicitly listed for Block
  64. # have the value No_Block.
  65. # Property: Block
  66. #
  67. # @missing: 0000..10FFFF; No_Block
  68. 0000..007F; Basic Latin
  69. 0080..00FF; Latin-1 Supplement
  70. 0100..017F; Latin Extended-A
  71. 0180..024F; Latin Extended-B
  72. 0250..02AF; IPA Extensions
  73. 02B0..02FF; Spacing Modifier Letters
  74. 0300..036F; Combining Diacritical Marks
  75. 0370..03FF; Greek and Coptic
  76. 0400..04FF; Cyrillic
  77. 0500..052F; Cyrillic Supplement
  78. 0530..058F; Armenian
  79. 0590..05FF; Hebrew
  80. 0600..06FF; Arabic
  81. 0700..074F; Syriac
  82. 0750..077F; Arabic Supplement
  83. 0780..07BF; Thaana
  84. 07C0..07FF; NKo
  85. 0800..083F; Samaritan
  86. 0840..085F; Mandaic
  87. 0860..086F; Syriac Supplement
  88. 0870..089F; Arabic Extended-B
  89. 08A0..08FF; Arabic Extended-A
  90. 0900..097F; Devanagari
  91. 0980..09FF; Bengali
  92. 0A00..0A7F; Gurmukhi
  93. 0A80..0AFF; Gujarati
  94. 0B00..0B7F; Oriya
  95. 0B80..0BFF; Tamil
  96. 0C00..0C7F; Telugu
  97. 0C80..0CFF; Kannada
  98. 0D00..0D7F; Malayalam
  99. 0D80..0DFF; Sinhala
  100. 0E00..0E7F; Thai
  101. 0E80..0EFF; Lao
  102. 0F00..0FFF; Tibetan
  103. 1000..109F; Myanmar
  104. 10A0..10FF; Georgian
  105. 1100..11FF; Hangul Jamo
  106. 1200..137F; Ethiopic
  107. 1380..139F; Ethiopic Supplement
  108. 13A0..13FF; Cherokee
  109. 1400..167F; Unified Canadian Aboriginal Syllabics
  110. 1680..169F; Ogham
  111. 16A0..16FF; Runic
  112. 1700..171F; Tagalog
  113. 1720..173F; Hanunoo
  114. 1740..175F; Buhid
  115. 1760..177F; Tagbanwa
  116. 1780..17FF; Khmer
  117. 1800..18AF; Mongolian
  118. 18B0..18FF; Unified Canadian Aboriginal Syllabics Extended
  119. 1900..194F; Limbu
  120. 1950..197F; Tai Le
  121. 1980..19DF; New Tai Lue
  122. 19E0..19FF; Khmer Symbols
  123. 1A00..1A1F; Buginese
  124. 1A20..1AAF; Tai Tham
  125. 1AB0..1AFF; Combining Diacritical Marks Extended
  126. 1B00..1B7F; Balinese
  127. 1B80..1BBF; Sundanese
  128. 1BC0..1BFF; Batak
  129. 1C00..1C4F; Lepcha
  130. 1C50..1C7F; Ol Chiki
  131. 1C80..1C8F; Cyrillic Extended-C
  132. 1C90..1CBF; Georgian Extended
  133. 1CC0..1CCF; Sundanese Supplement
  134. 1CD0..1CFF; Vedic Extensions
  135. 1D00..1D7F; Phonetic Extensions
  136. 1D80..1DBF; Phonetic Extensions Supplement
  137. 1DC0..1DFF; Combining Diacritical Marks Supplement
  138. 1E00..1EFF; Latin Extended Additional
  139. 1F00..1FFF; Greek Extended
  140. 2000..206F; General Punctuation
  141. 2070..209F; Superscripts and Subscripts
  142. 20A0..20CF; Currency Symbols
  143. 20D0..20FF; Combining Diacritical Marks for Symbols
  144. 2100..214F; Letterlike Symbols
  145. 2150..218F; Number Forms
  146. 2190..21FF; Arrows
  147. 2200..22FF; Mathematical Operators
  148. 2300..23FF; Miscellaneous Technical
  149. 2400..243F; Control Pictures
  150. 2440..245F; Optical Character Recognition
  151. 2460..24FF; Enclosed Alphanumerics
  152. 2500..257F; Box Drawing
  153. 2580..259F; Block Elements
  154. 25A0..25FF; Geometric Shapes
  155. 2600..26FF; Miscellaneous Symbols
  156. 2700..27BF; Dingbats
  157. 27C0..27EF; Miscellaneous Mathematical Symbols-A
  158. 27F0..27FF; Supplemental Arrows-A
  159. 2800..28FF; Braille Patterns
  160. 2900..297F; Supplemental Arrows-B
  161. 2980..29FF; Miscellaneous Mathematical Symbols-B
  162. 2A00..2AFF; Supplemental Mathematical Operators
  163. 2B00..2BFF; Miscellaneous Symbols and Arrows
  164. 2C00..2C5F; Glagolitic
  165. 2C60..2C7F; Latin Extended-C
  166. 2C80..2CFF; Coptic
  167. 2D00..2D2F; Georgian Supplement
  168. 2D30..2D7F; Tifinagh
  169. 2D80..2DDF; Ethiopic Extended
  170. 2DE0..2DFF; Cyrillic Extended-A
  171. 2E00..2E7F; Supplemental Punctuation
  172. 2E80..2EFF; CJK Radicals Supplement
  173. 2F00..2FDF; Kangxi Radicals
  174. 2FF0..2FFF; Ideographic Description Characters
  175. 3000..303F; CJK Symbols and Punctuation
  176. 3040..309F; Hiragana
  177. 30A0..30FF; Katakana
  178. 3100..312F; Bopomofo
  179. 3130..318F; Hangul Compatibility Jamo
  180. 3190..319F; Kanbun
  181. 31A0..31BF; Bopomofo Extended
  182. 31C0..31EF; CJK Strokes
  183. 31F0..31FF; Katakana Phonetic Extensions
  184. 3200..32FF; Enclosed CJK Letters and Months
  185. 3300..33FF; CJK Compatibility
  186. 3400..4DBF; CJK Unified Ideographs Extension A
  187. 4DC0..4DFF; Yijing Hexagram Symbols
  188. 4E00..9FFF; CJK Unified Ideographs
  189. A000..A48F; Yi Syllables
  190. A490..A4CF; Yi Radicals
  191. A4D0..A4FF; Lisu
  192. A500..A63F; Vai
  193. A640..A69F; Cyrillic Extended-B
  194. A6A0..A6FF; Bamum
  195. A700..A71F; Modifier Tone Letters
  196. A720..A7FF; Latin Extended-D
  197. A800..A82F; Syloti Nagri
  198. A830..A83F; Common Indic Number Forms
  199. A840..A87F; Phags-pa
  200. A880..A8DF; Saurashtra
  201. A8E0..A8FF; Devanagari Extended
  202. A900..A92F; Kayah Li
  203. A930..A95F; Rejang
  204. A960..A97F; Hangul Jamo Extended-A
  205. A980..A9DF; Javanese
  206. A9E0..A9FF; Myanmar Extended-B
  207. AA00..AA5F; Cham
  208. AA60..AA7F; Myanmar Extended-A
  209. AA80..AADF; Tai Viet
  210. AAE0..AAFF; Meetei Mayek Extensions
  211. AB00..AB2F; Ethiopic Extended-A
  212. AB30..AB6F; Latin Extended-E
  213. AB70..ABBF; Cherokee Supplement
  214. ABC0..ABFF; Meetei Mayek
  215. AC00..D7AF; Hangul Syllables
  216. D7B0..D7FF; Hangul Jamo Extended-B
  217. D800..DB7F; High Surrogates
  218. DB80..DBFF; High Private Use Surrogates
  219. DC00..DFFF; Low Surrogates
  220. E000..F8FF; Private Use Area
  221. F900..FAFF; CJK Compatibility Ideographs
  222. FB00..FB4F; Alphabetic Presentation Forms
  223. FB50..FDFF; Arabic Presentation Forms-A
  224. FE00..FE0F; Variation Selectors
  225. FE10..FE1F; Vertical Forms
  226. FE20..FE2F; Combining Half Marks
  227. FE30..FE4F; CJK Compatibility Forms
  228. FE50..FE6F; Small Form Variants
  229. FE70..FEFF; Arabic Presentation Forms-B
  230. FF00..FFEF; Halfwidth and Fullwidth Forms
  231. FFF0..FFFF; Specials
  232. 10000..1007F; Linear B Syllabary
  233. 10080..100FF; Linear B Ideograms
  234. 10100..1013F; Aegean Numbers
  235. 10140..1018F; Ancient Greek Numbers
  236. 10190..101CF; Ancient Symbols
  237. 101D0..101FF; Phaistos Disc
  238. 10280..1029F; Lycian
  239. 102A0..102DF; Carian
  240. 102E0..102FF; Coptic Epact Numbers
  241. 10300..1032F; Old Italic
  242. 10330..1034F; Gothic
  243. 10350..1037F; Old Permic
  244. 10380..1039F; Ugaritic
  245. 103A0..103DF; Old Persian
  246. 10400..1044F; Deseret
  247. 10450..1047F; Shavian
  248. 10480..104AF; Osmanya
  249. 104B0..104FF; Osage
  250. 10500..1052F; Elbasan
  251. 10530..1056F; Caucasian Albanian
  252. 10570..105BF; Vithkuqi
  253. 105C0..105FF; Todhri
  254. 10600..1077F; Linear A
  255. 10780..107BF; Latin Extended-F
  256. 10800..1083F; Cypriot Syllabary
  257. 10840..1085F; Imperial Aramaic
  258. 10860..1087F; Palmyrene
  259. 10880..108AF; Nabataean
  260. 108E0..108FF; Hatran
  261. 10900..1091F; Phoenician
  262. 10920..1093F; Lydian
  263. 10980..1099F; Meroitic Hieroglyphs
  264. 109A0..109FF; Meroitic Cursive
  265. 10A00..10A5F; Kharoshthi
  266. 10A60..10A7F; Old South Arabian
  267. 10A80..10A9F; Old North Arabian
  268. 10AC0..10AFF; Manichaean
  269. 10B00..10B3F; Avestan
  270. 10B40..10B5F; Inscriptional Parthian
  271. 10B60..10B7F; Inscriptional Pahlavi
  272. 10B80..10BAF; Psalter Pahlavi
  273. 10C00..10C4F; Old Turkic
  274. 10C80..10CFF; Old Hungarian
  275. 10D00..10D3F; Hanifi Rohingya
  276. 10D40..10D8F; Garay
  277. 10E60..10E7F; Rumi Numeral Symbols
  278. 10E80..10EBF; Yezidi
  279. 10EC0..10EFF; Arabic Extended-C
  280. 10F00..10F2F; Old Sogdian
  281. 10F30..10F6F; Sogdian
  282. 10F70..10FAF; Old Uyghur
  283. 10FB0..10FDF; Chorasmian
  284. 10FE0..10FFF; Elymaic
  285. 11000..1107F; Brahmi
  286. 11080..110CF; Kaithi
  287. 110D0..110FF; Sora Sompeng
  288. 11100..1114F; Chakma
  289. 11150..1117F; Mahajani
  290. 11180..111DF; Sharada
  291. 111E0..111FF; Sinhala Archaic Numbers
  292. 11200..1124F; Khojki
  293. 11280..112AF; Multani
  294. 112B0..112FF; Khudawadi
  295. 11300..1137F; Grantha
  296. 11380..113FF; Tulu-Tigalari
  297. 11400..1147F; Newa
  298. 11480..114DF; Tirhuta
  299. 11580..115FF; Siddham
  300. 11600..1165F; Modi
  301. 11660..1167F; Mongolian Supplement
  302. 11680..116CF; Takri
  303. 116D0..116FF; Myanmar Extended-C
  304. 11700..1174F; Ahom
  305. 11800..1184F; Dogra
  306. 118A0..118FF; Warang Citi
  307. 11900..1195F; Dives Akuru
  308. 119A0..119FF; Nandinagari
  309. 11A00..11A4F; Zanabazar Square
  310. 11A50..11AAF; Soyombo
  311. 11AB0..11ABF; Unified Canadian Aboriginal Syllabics Extended-A
  312. 11AC0..11AFF; Pau Cin Hau
  313. 11B00..11B5F; Devanagari Extended-A
  314. 11BC0..11BFF; Sunuwar
  315. 11C00..11C6F; Bhaiksuki
  316. 11C70..11CBF; Marchen
  317. 11D00..11D5F; Masaram Gondi
  318. 11D60..11DAF; Gunjala Gondi
  319. 11EE0..11EFF; Makasar
  320. 11F00..11F5F; Kawi
  321. 11FB0..11FBF; Lisu Supplement
  322. 11FC0..11FFF; Tamil Supplement
  323. 12000..123FF; Cuneiform
  324. 12400..1247F; Cuneiform Numbers and Punctuation
  325. 12480..1254F; Early Dynastic Cuneiform
  326. 12F90..12FFF; Cypro-Minoan
  327. 13000..1342F; Egyptian Hieroglyphs
  328. 13430..1345F; Egyptian Hieroglyph Format Controls
  329. 13460..143FF; Egyptian Hieroglyphs Extended-A
  330. 14400..1467F; Anatolian Hieroglyphs
  331. 16100..1613F; Gurung Khema
  332. 16800..16A3F; Bamum Supplement
  333. 16A40..16A6F; Mro
  334. 16A70..16ACF; Tangsa
  335. 16AD0..16AFF; Bassa Vah
  336. 16B00..16B8F; Pahawh Hmong
  337. 16D40..16D7F; Kirat Rai
  338. 16E40..16E9F; Medefaidrin
  339. 16F00..16F9F; Miao
  340. 16FE0..16FFF; Ideographic Symbols and Punctuation
  341. 17000..187FF; Tangut
  342. 18800..18AFF; Tangut Components
  343. 18B00..18CFF; Khitan Small Script
  344. 18D00..18D7F; Tangut Supplement
  345. 1AFF0..1AFFF; Kana Extended-B
  346. 1B000..1B0FF; Kana Supplement
  347. 1B100..1B12F; Kana Extended-A
  348. 1B130..1B16F; Small Kana Extension
  349. 1B170..1B2FF; Nushu
  350. 1BC00..1BC9F; Duployan
  351. 1BCA0..1BCAF; Shorthand Format Controls
  352. 1CC00..1CEBF; Symbols for Legacy Computing Supplement
  353. 1CF00..1CFCF; Znamenny Musical Notation
  354. 1D000..1D0FF; Byzantine Musical Symbols
  355. 1D100..1D1FF; Musical Symbols
  356. 1D200..1D24F; Ancient Greek Musical Notation
  357. 1D2C0..1D2DF; Kaktovik Numerals
  358. 1D2E0..1D2FF; Mayan Numerals
  359. 1D300..1D35F; Tai Xuan Jing Symbols
  360. 1D360..1D37F; Counting Rod Numerals
  361. 1D400..1D7FF; Mathematical Alphanumeric Symbols
  362. 1D800..1DAAF; Sutton SignWriting
  363. 1DF00..1DFFF; Latin Extended-G
  364. 1E000..1E02F; Glagolitic Supplement
  365. 1E030..1E08F; Cyrillic Extended-D
  366. 1E100..1E14F; Nyiakeng Puachue Hmong
  367. 1E290..1E2BF; Toto
  368. 1E2C0..1E2FF; Wancho
  369. 1E4D0..1E4FF; Nag Mundari
  370. 1E5D0..1E5FF; Ol Onal
  371. 1E7E0..1E7FF; Ethiopic Extended-B
  372. 1E800..1E8DF; Mende Kikakui
  373. 1E900..1E95F; Adlam
  374. 1EC70..1ECBF; Indic Siyaq Numbers
  375. 1ED00..1ED4F; Ottoman Siyaq Numbers
  376. 1EE00..1EEFF; Arabic Mathematical Alphabetic Symbols
  377. 1F000..1F02F; Mahjong Tiles
  378. 1F030..1F09F; Domino Tiles
  379. 1F0A0..1F0FF; Playing Cards
  380. 1F100..1F1FF; Enclosed Alphanumeric Supplement
  381. 1F200..1F2FF; Enclosed Ideographic Supplement
  382. 1F300..1F5FF; Miscellaneous Symbols and Pictographs
  383. 1F600..1F64F; Emoticons
  384. 1F650..1F67F; Ornamental Dingbats
  385. 1F680..1F6FF; Transport and Map Symbols
  386. 1F700..1F77F; Alchemical Symbols
  387. 1F780..1F7FF; Geometric Shapes Extended
  388. 1F800..1F8FF; Supplemental Arrows-C
  389. 1F900..1F9FF; Supplemental Symbols and Pictographs
  390. 1FA00..1FA6F; Chess Symbols
  391. 1FA70..1FAFF; Symbols and Pictographs Extended-A
  392. 1FB00..1FBFF; Symbols for Legacy Computing
  393. 20000..2A6DF; CJK Unified Ideographs Extension B
  394. 2A700..2B73F; CJK Unified Ideographs Extension C
  395. 2B740..2B81F; CJK Unified Ideographs Extension D
  396. 2B820..2CEAF; CJK Unified Ideographs Extension E
  397. 2CEB0..2EBEF; CJK Unified Ideographs Extension F
  398. 2EBF0..2EE5F; CJK Unified Ideographs Extension I
  399. 2F800..2FA1F; CJK Compatibility Ideographs Supplement
  400. 30000..3134F; CJK Unified Ideographs Extension G
  401. 31350..323AF; CJK Unified Ideographs Extension H
  402. E0000..E007F; Tags
  403. E0100..E01EF; Variation Selectors Supplement
  404. F0000..FFFFF; Supplementary Private Use Area-A
  405. 100000..10FFFF; Supplementary Private Use Area-B
  406. # EOF
  407. ''')
  408. f.append(fontforge.open("fonts/NotoSansSymbols-Regular.ttf"))
  409. f.append(fontforge.open("fonts/NotoSansSymbols2-Regular.ttf"))
  410. f.append(fontforge.open("fonts/NotoEmoji-Regular.ttf"))
  411. f.append(fontforge.open("fonts/NotoSansMath-Regular.ttf"))
  412. for i in range(len(f)):
  413. for glyph in f[i].glyphs():
  414. b=uniblock(glyph.unicode)
  415. if b is not None:
  416. _blocks[b][3].append(glyph.unicode)
  417. irow=0;
  418. row=40;
  419. for i in range(len(_blocks)):
  420. if i==0:
  421. continue # no latin needed
  422. irow=0;
  423. if len(_blocks[i][3])==0:
  424. continue;
  425. name=_blocks[i][2].upper().replace(" ", "_").replace("-", "_")
  426. gen.write("// "+_blocks[i][2]+"\n#ifndef _LA_ICO_"+name+"\n#define _LA_ICO_"+name+" \\\n")
  427. for c in _blocks[i][3]:
  428. if (irow%row==0):
  429. gen.write("\"")
  430. gen.write(str(chr(c)));
  431. written+=1;
  432. irow+=1
  433. if (irow%row==0):
  434. gen.write("\" \\\n")
  435. if (irow%row!=0):
  436. gen.write("\"\n")
  437. gen.write(";\n#endif\n\n")
  438. gen.write("// Generated %s characters\n"%(written));
  439. gen.write("// Glyphs with no names: %d\n// "%len(no_name));
  440. for n in no_name:
  441. gen.write(chr(n));
  442. gen.close()