2019独角兽企业重金招聘Python工程师标准>>>
3个要点:
1、使用pygame引擎绘制文本
2、使用字体文件名作为标识,而不是字体名。如msya:微软雅黑,simkai:楷体,simsun:宋体。
3、把字体文件拷贝到程序所在文件夹。其中simsun.ttf原名simsun.ttc,以为不支持ttc的文件,所以改名为ttf以蒙混过关
# -*- coding: utf-8 -*-
"""
Created on Thu May 18 14:30:59 2017@author: zbg
"""
from psychopy.visual import Window, TextStim
from psychopy import eventwin = Window(size = (150, 200), winType = "pygame")
print win.winType
a = TextStim(win, text = u"你好", units = 'pix', height = 55, font = "msyh")
a.draw()
a = TextStim(win, text = u"你好", units = 'pix', height = 55, font = "simkai", pos = (0, -55))
a.draw()
a = TextStim(win, text = u"你好", units = 'pix', height = 55, font = "simsun", pos = (0, 55))
a.draw()
win.flip()
event.waitKeys(["space"])
效果
更多psychopy程序,尽在:
https://item.taobao.com/item.htm?spm=a230r.1.14.1.QRZDJq&id=530690095131&ns=1&abbucket=6#detail