Created
July 13, 2019 22:39
-
-
Save Uristqwerty/882697ab05143e7ccf6aeda1dd57c89d to your computer and use it in GitHub Desktop.
Did you know Unicode has italic letters? And bold. And sans-serif-italic-bold. And Fraktur, whatever that is. Also, did you know that on some forums, you can combine both Unicode and markdown/BBCode/etc. italics, for doubly-slanty words? This short blob of JavaScript can be dumped into any browser console and to assist in text decoration shenaniโฆ
This file contains hidden or 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
/* Letter variants collected from https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols_(Unicode_block) */ | |
let alphabets = { | |
plain: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.split(''), | |
sans: '๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ ๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป ๐ผ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ'.split(' '), | |
serif_italic: '๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป ๐ผ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ โ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง 0 1 2 3 4 5 6 7 8 9'.split(' '), | |
sans_italic: '๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ ๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป 0 1 2 3 4 5 6 7 8 9'.split(' '), | |
serif_bold: '๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ ๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐'.split(' '), | |
sans_bold: '๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ ๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป ๐ผ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต'.split(' '), | |
serif_bold_italic: '๐จ ๐ฉ ๐ช ๐ซ ๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป ๐ผ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ 0 1 2 3 4 5 6 7 8 9'.split(' '), | |
sans_bold_italic: '๐ผ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ ๐ฌ ๐ญ ๐ฎ ๐ฏ 0 1 2 3 4 5 6 7 8 9'.split(' '), | |
script: '๐ โฌ ๐ ๐ โฐ โฑ ๐ข โ โ ๐ฅ ๐ฆ โ โณ ๐ฉ ๐ช ๐ซ ๐ฌ โ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น โฏ ๐ป โ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ โด ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ 0 1 2 3 4 5 6 7 8 9'.split(' '), | |
script_bold: '๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ ๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป ๐ผ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ 0 1 2 3 4 5 6 7 8 9'.split(' '), | |
fraktur: '๐ ๐ โญ ๐ ๐ ๐ ๐ โ โ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ โ ๐ ๐ ๐ ๐ ๐ ๐ ๐ โจ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ ๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท 0 1 2 3 4 5 6 7 8 9'.split(' '), | |
fraktur_bold: '๐ฌ ๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป ๐ผ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ 0 1 2 3 4 5 6 7 8 9'.split(' '), | |
monospace: '๐ฐ ๐ฑ ๐ฒ ๐ณ ๐ด ๐ต ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป ๐ผ ๐ฝ ๐พ ๐ฟ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ถ ๐ท ๐ธ ๐น ๐บ ๐ป ๐ผ ๐ฝ ๐พ ๐ฟ'.split(' '), | |
double_struck: '๐ธ ๐น โ ๐ป ๐ผ ๐ฝ ๐พ โ ๐ ๐ ๐ ๐ ๐ โ ๐ โ โ โ ๐ ๐ ๐ ๐ ๐ ๐ ๐ โค ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก ๐ข ๐ฃ ๐ค ๐ฅ ๐ฆ ๐ง ๐จ ๐ฉ ๐ช ๐ซ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ก'.split(' '), | |
superscript: 'แดฌ แดฎ C แดฐ แดฑ F แดณ แดด แดต แดถ แดท แดธ แดน แดบ แดผ แดพ Q แดฟ S แต แต โฑฝ แต X Y Z แต แต แถ แต แต แถ แต สฐ โฑ สฒ แต หก แต โฟ แต แต q สณ หข แต แต แต สท หฃ สธ แถป โฐ ยน ยฒ ยณ โด โต โถ โท โธ โน'.split(' '), | |
subscript: 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z โ b c d โ f g โ แตข โฑผ โ โ โ โ โ โ q แตฃ โ โ แตค แตฅ w โ y z โ โ โ โ โ โ โ โ โ โ'.split(' '), | |
small_caps: 'แด ส แด แด แด ๊ฐ ษข ส ษช แด แด ส แด ษด แด แด ๊ฏ ส ๊ฑ แด แด แด แดก X ส แดข a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9' | |
} | |
function map_alphabets(text, from, to) { | |
let result = ''; | |
for(let ch of text) { | |
let idx = from.indexOf(ch); | |
result += idx < 0? ch : to[idx]; | |
} | |
return result; | |
} | |
function italicize(text, serif) { | |
return map_alphabets(text, alphabets.plain, serif? alphabets.serif_italic : alphabets.sans_italic); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment