Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import subprocess
  2.  
  3. import cairo
  4. import wx
  5. import wx.lib.wxcairo
  6.  
  7. WIDTH = 400
  8. HEIGHT = 300
  9.  
  10. surface = cairo.ImageSurface(
  11. cairo.FORMAT_RGB24,
  12. WIDTH,
  13. HEIGHT
  14. )
  15. ctx = cairo.Context(surface)
  16. ctx.rectangle(0, 0, WIDTH, HEIGHT)
  17. ctx.set_source_rgb(0.8, 0.8, 1)
  18. ctx.fill()
  19.  
  20. # Drawing code
  21. app = wx.App()
  22. wfont = wx.Font(
  23. 13,
  24. wx.FONTFAMILY_DEFAULT,
  25. wx.FONTSTYLE_NORMAL,
  26. wx.FONTWEIGHT_NORMAL,
  27. False,
  28. '蘋果儷細宋'
  29. )
  30. cfont = wx.lib.wxcairo.FontFaceFromFont(wfont)
  31. ctx.set_font_face(cfont)
  32. ctx.set_font_size(13)
  33. ctx.set_source_rgb(0, 0, 0)
  34. ctx.move_to(20, 80)
  35. ctx.show_text('Your grand mom, 你啊罵勒')
  36. # End of drawing code
  37.  
  38. surface.write_to_png('text.png')
  39. subprocess.run(['open', 'text.png'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement