Skip to content

Instantly share code, notes, and snippets.

@uktechreviews
Last active May 28, 2018 18:44
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 uktechreviews/be2bc2ce74e54a0bf776808be4df53c9 to your computer and use it in GitHub Desktop.
Save uktechreviews/be2bc2ce74e54a0bf776808be4df53c9 to your computer and use it in GitHub Desktop.
Code examples for Bible
# Test font size to determine the maximum number of characters per line and should match the default font used in draw_text
test_font = inkyphat.ImageFont.truetype(inkyphat.fonts.AmaticSC,20)
w, h = test_font.getsize("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ")
max_char = int((212/(w/36)))
quotes = open("quotes", "r")
lines = quotes.readlines()
quotes.close()
maximum = len(lines)
choice=(randint(1,maximum-1))
test = str(lines[choice])
text = [test[i:i+max_char] for i in range(0,len(test),max_char)]
for i in range(len(text)):
new_text=text[i]
if (new_text[max_char-1:max_char])!=" ":
new_text=new_text+"-"
if (new_text[-2:-1:])==".":
new_text=new_text[:-1]
if (new_text[-2:-1:])==",":
new_text=new_text[:-1]
if (new_text[-2:-1:])==";":
new_text=new_text[:-1]
if (new_text[-2:-1:])==":":
new_text=new_text[:-1]
if (new_text[-2:-1:])==" ":
new_text=new_text[:-1]
text[i]=new_text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment