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

您所在的位置:网站首页 邮件微软雅黑字体多大合适 psychopy设置中文显示字体 楷体、宋体、微软雅黑

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

2024-07-15 03:21| 来源: 网络整理| 查看: 265

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

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 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3