无法使用 Tkinter 生成 postscript 文件

Unable to generate postscript file using Tkinter

在 ubuntu 16.04 中,无法查看使用下面的 python 程序创建的 postscript 文件:

from Tkinter import *
root = Tk()
c = Canvas(root)
c.pack()
c.create_text(0, 0, text = 'Hello', anchor=NW)
c.update()
c.postscript(file = 'hello.ps')

在文本编辑器中查看 postscript 文件会显示以下部分:

/DejavuSans findfont 0 scalefont ISOEncode setfont
0.000 0.000 0.000 setrgbcolor AdjustColor
0 0 267 [
[(Hello)]
] 14 -0 0 0 false DrawText

手动将字体改成say 9后,可以查看后记文件

如何解决这个问题,以便 Tkinter 生成正确的 postscript 文件?任何建议...

您可以使用font=设置字体和大小。也许有帮助。

c.create_text(0, 0, text='Hello', anchor=NW, font=('DejavuSans', '9'))

更多:Type fonts