tags:

views:

23

answers:

1

Hi All,

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"
+1  A: 

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.

Donal Fellows
Thank you for replying me with detail explanations! I was forced to switch to Java for a solution. It seemed Java handles Unicode better.
Jin
Well, they've had more money thrown at this (admittedly very tricky) problem.
Donal Fellows