MathML mathvariant Unicode table
Note: JSON does not support integer keys, so we can't store the result of maketrans as a JSON file.
import json
from pathlib import Path
def load(path):
return json.loads(path.read_text(encoding="utf-8"))
def maketrans(fonts):
return {
font_name: str.maketrans(alphabet)
for font_name, alphabet in fonts.items()
}
mathvariant = maketrans(load(Path("mathvariant.json")))
# Example use
print("ABC".translate(mathvariant["fraktur"])) # 𝔄𝔅ℭ
print(mathvariant["fraktur"][ord("A")]) # 𝔄