73 lines
2.9 KiB
Python
73 lines
2.9 KiB
Python
import os
|
|
import yaml
|
|
import cgi
|
|
from pathlib import Path
|
|
|
|
stream = open(os.getcwd() + "/../fontcharacter/reference/characters.yml", "r")
|
|
docs = yaml.load_all(stream)
|
|
|
|
print("# Casio Charset\n")
|
|
print("|Casio value|Casio font (normal) |Casio font (mini) |Unicode character|Meaning <span style=\"visibility: hidden;\">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span>|ASCII value|Unicode value|");
|
|
print("|-----------|:----------------------------------------------------------------------:|:----------------------------------------------------------------------:|:---------------:|----------------------------------------------------|-----------|-------------|")
|
|
|
|
for doc in docs:
|
|
for charspec in doc:
|
|
#print(charspec)
|
|
code = charspec.get("code")
|
|
name = charspec.get("name")
|
|
category = charspec.get("category")
|
|
unicode = charspec.get("unicode")
|
|
multi = charspec.get("multi")
|
|
tokens = charspec.get("tokens")
|
|
id_ = charspec.get("id")
|
|
|
|
args = charspec.get("args")
|
|
action = charspec.get("action")
|
|
return_ = charspec.get("return")
|
|
flags = charspec.get("flags")
|
|
ascii_ = charspec.get("ascii")
|
|
|
|
tab_code = ("0x%02X" % code)
|
|
|
|
if Path(os.getcwd() + "/../casio_charset/normal/0x%02X.png" % code).exists():
|
|
tab_pic_normal = "![ ](casio_charset/normal/0x%02X.png){class=\"normal_font pixelated\" onerror=\"reload_img(this);\"}" % code
|
|
else:
|
|
tab_pic_normal = ""
|
|
|
|
if Path(os.getcwd() + "/../casio_charset/mini/0x%02X.png" % code).exists():
|
|
tab_pic_mini = "![ ](casio_charset/mini/0x%02X.png){class=\"mini_font pixelated\" onerror=\"reload_img(this);\"}" % code
|
|
else:
|
|
tab_pic_mini = ""
|
|
|
|
tab_char = ""
|
|
if code == 0x0D:
|
|
tab_char = "" # '\n'
|
|
elif code == 0x20:
|
|
tab_char = " " # ' '
|
|
elif code == 0x7c:
|
|
tab_char = "|" # '|'
|
|
elif unicode is not None:
|
|
for u in unicode:
|
|
tab_char = tab_char + chr(u).encode("ascii", "xmlcharrefreplace").decode('utf-8')
|
|
|
|
tab_meaning = name
|
|
if args is not None:
|
|
tab_meaning = tab_meaning + "<br/>args: " + ",".join(args)
|
|
if return_ is not None:
|
|
tab_meaning = tab_meaning + "<br/>return: " + return_
|
|
|
|
tab_ascii = []
|
|
tab_unicode = []
|
|
|
|
if unicode is not None:
|
|
for u in unicode:
|
|
if u <= 0xFF:
|
|
tab_ascii.append("0x%02X" % u)
|
|
else:
|
|
tab_unicode.append("0x%02X" % u)
|
|
tab_ascii = ",".join(tab_ascii)
|
|
tab_unicode = ",".join(tab_unicode)
|
|
|
|
print("| %9s | %70s | %70s | %15s | %50s | %9s | %11s |" % (tab_code, tab_pic_normal, tab_pic_mini, tab_char, tab_meaning, tab_ascii, tab_unicode))
|
|
|