如何从 Tcl/Tk 库的 Canvas 对象将文本生成为 postscript 文件?
我已经被这个问题困扰好几天了: 我正在尝试使用画布对象的“postscript”选项生成文本来获取 .ps 文件。我发现如果我在画布上绘制线条、椭圆形等并且它们显示在 .ps 文件中,效果很好,但是,我对文本对象没有运气 - 即使它们显示在画布上(在显示上) ),输出 .ps 文件中未捕获。
有人对此有想法吗?您可以假设所有变量都已明确定义。
wm geometry . +0+0
wm resizable . false false
set wtitle "Drawing Chinese Character"
frame .frm -width $pad_width -height $pad_height -relief raised -bd 2
canvas .p0 -width $pad_width -height $pad_height -relief raised -bd 0
.p0 create rectangle 0 0 $pad_width $pad_height -outline gray -fill white -width 0
.p0 create text $akx $aky -text "\u9177" -font -Adobe-Times-Bold-R-Normal-*-$fontsize-*
.p0 create line 0 0 $pad_width $pad_height -fill red -width 2 -arrow last
pack .p0 -in .frm -fill both
pack .frm -side bottom
update;
.p0 postscript -fontmap fontMap -file "char.ps"
I've been stuck on this problem for days:
I'm trying to generate texts from the canvas object using its "postscript" option to get .ps file. I found that it worked fine if I draw lines, ovals, etc on the canvas and they were shown in the .ps file, however, I had no luck with the text objects -- even if they were shown on the canvas (on display), there were not captured in the output .ps file.
Anyone has a thought on this? You can assume all the variables are well-defined.
wm geometry . +0+0
wm resizable . false false
set wtitle "Drawing Chinese Character"
frame .frm -width $pad_width -height $pad_height -relief raised -bd 2
canvas .p0 -width $pad_width -height $pad_height -relief raised -bd 0
.p0 create rectangle 0 0 $pad_width $pad_height -outline gray -fill white -width 0
.p0 create text $akx $aky -text "\u9177" -font -Adobe-Times-Bold-R-Normal-*-$fontsize-*
.p0 create line 0 0 $pad_width $pad_height -fill red -width 2 -arrow last
pack .p0 -in .frm -fill both
pack .frm -side bottom
update;
.p0 postscript -fontmap fontMap -file "char.ps"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是生成的编码中许多 UNICODE 字符的处理不完整(一个错误!)。特别是,字符
\u9177
未定义(在 Tk 安装库目录的mkpsenc.tcl
中)和输出文本的代码无论如何都不能正确处理这些事情。此外,对此采取一些措施非常棘手,因为在核心拉丁字母之外,有必要注意字形和字符之间的映射。我们欢迎贡献代码来解决这个问题,但这很困难。 (如果我们能够放弃所有复杂性,只将 UTF-8 发送到打印机,那就太好了;从我们的角度来看,这将一次性解决问题。但我不知道这在一般情况下是否可行。 )
恐怕这不是你想要的答案。
The problem is that the handling of many UNICODE characters in the encoding generated is incomplete (a bug!). In particular, the character
\u9177
is not defined (inmkpsenc.tcl
in your Tk installation's library directory) and the code to output text just doesn't handle these things correctly anyway.Moreover, doing something about this is deeply tricky because outside of the core Latin alphabet it becomes necessary to take care about the mapping between glyphs and characters. We welcome contributions of code to fix this, but it's difficult. (What would be very nice is if we could drop all that complexity and just send UTF-8 to the printer; that would solve the problems from our perspective in one go. But I don't know if that's possible on a general basis.)
Not the answer you wanted, I fear.