psychopy设置中文显示字体 楷体、宋体、微软雅黑

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 event

win = 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 

转载于:https://my.oschina.net/zbaigao/blog/903656

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值