Created
February 28, 2019 14:24
-
-
Save LettError/5b56cf940d962f5d6c6e3caed9cbbee3 to your computer and use it in GitHub Desktop.
A small converter from normal latin AZ,az to the Unicode math alphabets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
self.w.style = vanilla.SegmentedButton((5, 5, -5, 20), segmentDescriptions=self.styles, callback=self.selectStyleCallback ) | |
self.w.style.set(0) | |
self.newInputCallback() | |
self.w.open() | |
def selectStyleCallback(self, sender): | |
self.styleIndex = sender.get() | |
self.newInputCallback() | |
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) | |
else: | |
new += c | |
self.w.o.set(new) | |
OpenWindow(StyleWriter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment