# Inverted text in Ruby Tk canvas postscript

**URL:** <https://www.ruby-forum.com/t/inverted-text-in-ruby-tk-canvas-postscript/140492>\
**Category:** Ruby\
**Created:** [June 14, 2008, 11:43pm UTC](https://www.ruby-forum.com/t/inverted-text-in-ruby-tk-canvas-postscript/140492 "2008-06-14T23:43:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarazed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ed8c4c/32.png) [@tarazed](https://www.ruby-forum.com/u/tarazed)\
**Post date:** [June 14, 2008, 11:43pm UTC](https://www.ruby-forum.com/t/inverted-text-in-ruby-tk-canvas-postscript/140492/1 "2008-06-14T23:43:41Z")

</div>

A new problem with ruby-tk, specific to ruby1.8.7. The underlying tk  
version has not changed but now text in a postscript file generated from  
a tk canvas is mirror imaged about both horizontal and vertical axes.  
Line by line comparison with a corresponding file output from tcl  
shows that the prolog code is exactly the same. The text however is  
handled differently. Ruby treats lines belonging to the same block as  
a single group, which is good, but now inserts a minus sign in front  
of the fontsize in each findfont line, e.g.

/URWGothicL-Book findfont -17 scalefont ISOEncode setfont

whereas Tcl has:

/URWGothicL-Book findfont 17 scalefont ISOEncode setfont

which works as expected.

The workaround for this is to preprocess the postscript output before  
writing to a file, easy enough to do but hopefully unecessary in later  
versions of ruby-tk.

changes = 0  
screed.each { |line|  
if i = line.index( “findfont -” ) :  
line.sub!( “findfont -”, "findfont " )  
changes += 1  
end  
}

It looks like it might be an internationalization issue given that not  
all nations read from left to right and top to bottom and it may come  
out in the wash once the tk canvas is absorbed into the ttk themed  
widget set.

Len
