Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A small converter from normal latin AZ,az to the Unicode math alphabets.
import vanilla
""" Unicode Stylewriter: Use the unicode styles to impress friends and families on the internet. """
class StyleWriter(object):
styles = [
dict(title="𝔸", upper=0x1D538, lower=0x1D552, name='mathdoublestruck'),
dict(title="𝖠", upper=0x1D5A0, lower=0x1D5BA, name='mathsans'),
dict(title="𝗔", upper=0x1D5D4, lower=0x1D5EE, name='mathsansbold'),
dict(title="𝐴", upper=0x1D434, lower=0x1D44E, name='mathitalic'),
dict(title="𝐀", upper=0x1D400, lower=0x1D41A, name='mathbold'),
dict(title="𝑨", upper=0x1D468, lower=0x1D482, name='mathbolditalic'),
dict(title="𝒜", upper=0x1D49C, lower=0x1D4B6, name='mathscript'),
dict(title="𝓐", upper=0x1D4D0, lower=0x1D4EA, name='mathscriptbold'),
dict(title="𝔄", upper=0x1D504, lower=0x1D51E, name='mathfraktur'),
dict(title="𝕬", upper=0x1D56C, lower=0x1D586, name='mathfrakturebold'),
def __init__(self):
text = "Unicode StyleWriter"
self.styleIndex = 0
self.w = vanilla.Window((400,300), "Unicode StyleWriter")
self.w.t = vanilla.EditText((0,40,0,120), text, placeholder="Type Text Here", continuous=True, callback=self.newInputCallback)
self.w.o = vanilla.EditText((0,160,0,0), "Output") = vanilla.SegmentedButton((5, 5, -5, 20), segmentDescriptions=self.styles, callback=self.selectStyleCallback )
def selectStyleCallback(self, sender):
self.styleIndex = sender.get()
def newInputCallback(self, sender=None):
data = self.w.t.get()
new = ""
for c in data:
if 65 <= ord(c) <= 90:
new += chr(ord(c) + self.styles[self.styleIndex]['upper']-65)
elif 97 <= ord(c) <= 122:
new += chr(ord(c) + self.styles[self.styleIndex]['lower']-97)
new += c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment