Advertisement
here2share

# measure_text_demo.py

Jan 9th, 2015
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # measure_text_demo.py
  2.  
  3. import appuifw, e32, graphics
  4. import math
  5.  
  6. def draw(rect):
  7.     try: canvas.blit(img)
  8.     except: pass
  9.  
  10. def quit():
  11.     script_lock.signal()
  12.  
  13. canvas = appuifw.Canvas(redraw_callback=draw)
  14. appuifw.app.directional_pad=False
  15. appuifw.app.orientation='portrait'
  16. appuifw.app.screen='large'
  17. appuifw.app.body=canvas
  18. w,h = canvas.size
  19. img=graphics.Image.new((w,h))
  20.  
  21. msg="Thank You Very Much!"
  22. bounds, to_right, count = img.measure_text(unicode(msg, 'utf-8'))
  23. print
  24. print msg
  25. print bounds
  26. print to_right
  27. print count # similar to len()
  28. img.text((bounds[0],bounds[1]*-1), unicode(msg, 'utf-8'), fill=(255,0,0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement