如何从 Tcl/Tk 库的 Canvas 对象将文本生成为 postscript 文件?

发布于 2024-09-25 02:19:54 字数 798 浏览 5 评论 0原文

我已经被这个问题困扰好几天了: 我正在尝试使用画布对象的“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゝ偶尔ゞ 2024-10-02 02:19:54

问题是生成的编码中许多 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 (in mkpsenc.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文