Skip to content

Instantly share code, notes, and snippets.

@fitnr
Last active May 19, 2017 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitnr/695f1f088943831756dbf38c67db1a73 to your computer and use it in GitHub Desktop.
Save fitnr/695f1f088943831756dbf38c67db1a73 to your computer and use it in GitHub Desktop.
Make your text wide and imposing using Python 3. A̮̍d̦ͭd̳̓ cͮͅr̊͡ä̫́zͬ̈́y͉͓ dͤ̕iͦ̃a̧̬c̢̙r͊̄e͞ͅt̳̔i̦̓c̩͜s͚̲ t̴͙o̢̬ y̞͟o͕͟u̬̖r̴̬ t͓̭é͟x̗͊t̥͉
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import string
from random import sample
# Add random diacretics to a text
diacretics = [chr(x) for x in range(0x300, 0x36F)]
# don't add marks to whitespace or punctuation
reserved = ' ' + string.whitespace + string.punctuation
def add_diacretics(string, num=None):
num = num or 1
return ''.join(s + (''.join(sample(diacretics, num)) if s not in reserved else '') for s in string)
# add_diacretics('Hello World')
# 'Ḣēl͗l͢oͨ W̊o͉r̩l͐d̸'
# add_diacretics('Hello World', 25)
# H͓̮͗͏̶̴̧̡̨̘̭͇̻̜ͫ͐͂ͦ͌̂ͨ̿̓ͤ̔ȩ̡̰͕͔̫͎̘̋́̑̉̌́͌ͤ̾ͬͫ̈́̔̚͘͢ͅl̶͙̱̘̤͈̜̻͕͖̓̃ͭ́ͣ̎̄̈́͌͐͜͞͝͡ͅḻ̵̻̩̟̞̹̰̤̥̋͂ͩ̂̊̀̑͗ͪ͋̔͆͊̉͠ơ̶̡̫̥̦͉̪͕̜̤͚̺̓͊ͮ̅̑̈̆͌͑ͩ̚̕ W̷̡̟͍̱͎̠̥̻̗̮͚ͪ̋́ͣ̊́ͬ̾̽͜͠͞ͅờ̴̸͖̲̬̺̠̹͙̭͈͊ͬ̑̆͒͋ͭ̈́ͫ̓͗͜ṛ̱̭̲͓̳̘̯̦̗̫̅ͥͧ̈͋̏͑̂ͪ́̾̀͞͠l̸̨̧͓̰̺̫̤̻̯̟̮͔̓̿͛̏̽͒̔ͧ͗̈̇͝d̀͏̶̨̧̢͖̬͉̜̱͙̪̞̼ͫ̽̇ͤ̎̒͛̉͐͡
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import string
import unicodedata
# Make your text wide and imposing using Python 3
fullwidth = (' abcdefghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
'0123456789!"#$%&'()*+,-./:'
';<=>?@[\]^_`{|}~¢£¦¥₩'
)
singlewidth = ' ' + string.ascii_letters + string.digits + string.punctuation + "¢£¦¥₩"
table = str.maketrans(singlewidth, fullwidth)
def make_wide(string):
return unicodedata.normalize('NFD', string.translate(table))
# print(make_wide('HELLO WORLD'))
# HELLO WORLD
# print (make_wide('évén wørks wìth diaçretics'))
# évén wørks wìth diaçretics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment