Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import cairo
- import wx
- import wx.lib.wxcairo
- WIDTH = 400
- HEIGHT = 300
- surface = cairo.ImageSurface(
- cairo.FORMAT_RGB24,
- WIDTH,
- HEIGHT
- )
- ctx = cairo.Context(surface)
- ctx.rectangle(0, 0, WIDTH, HEIGHT)
- ctx.set_source_rgb(0.8, 0.8, 1)
- ctx.fill()
- # Drawing code
- app = wx.App()
- wfont = wx.Font(
- 13,
- wx.FONTFAMILY_DEFAULT,
- wx.FONTSTYLE_NORMAL,
- wx.FONTWEIGHT_NORMAL,
- False,
- '蘋果儷細宋'
- )
- cfont = wx.lib.wxcairo.FontFaceFromFont(wfont)
- ctx.set_font_face(cfont)
- ctx.set_font_size(13)
- ctx.set_source_rgb(0, 0, 0)
- ctx.move_to(20, 80)
- ctx.show_text('Your grand mom, 你啊罵勒')
- # End of drawing code
- surface.write_to_png('text.png')
- subprocess.run(['open', 'text.png'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement