This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
From: Slaven Rezic <slaven@rezic.de> Subject: Re: rotated text Newsgroups: comp.lang.perl.tk Date: 21 Feb 2004 19:16:52 +0100 merlyn@stonehenge.com (Randal L. Schwartz) writes: > I'm just now (re-)learning Perl-Tk. I don't see any way to > have rotated text. Did I just miss it? There's no Tk-level support for rotated fonts. However, if you need the feature for X11-only, you can use font names with transformation matrixes. Another way is to use an external module like GD, Imager or ImageMagick to do the transformation. Both solutions could be found in this experimental module: http://user.cs.tu-berlin.de/~eserte/src/perl/Tk-CanvasRottext/ === From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> Subject: Re: rotated text Newsgroups: comp.lang.perl.tk Date: Sat, 21 Feb 2004 19:47:57 GMT Slaven Rezic wrote: > There's no Tk-level support for rotated fonts. However, if you need > the feature for X11-only, you can use font names with transformation > matrixes. That reminds me. I found a way a while ago to draw rotated text on Win32 using Win32::API, but it had some drawbacks: - Sometimes some weird characters appeared at the end of the string. It could simply be the way strings are terminated on win32 systems. - Tk didn't seem to "see" the text, and if a widget needs to take over the space held by the text, then it would do so. - The text disappeared when the mainwindow was moved (I think any <Configure> event had the same effect). I'll try to dig up the code. It's on an old HD lying somewhere around. Perhaps combining this with the X11 transformation matrices will produce a workable solution on X11/Win32. Mac owners won't be happy, but I think they're used to this by now :-) === From: Slaven Rezic <slaven@rezic.de> Subject: Re: rotated text Newsgroups: comp.lang.perl.tk Date: 22 Feb 2004 11:37:02 +0100 Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> writes: > Slaven Rezic wrote: > > > There's no Tk-level support for rotated fonts. However, if you need > > the feature for X11-only, you can use font names with transformation > > matrixes. > > That reminds me. I found a way a while ago to draw rotated text on > Win32 using Win32::API, but it had some drawbacks: > > - Sometimes some weird characters appeared at the end of the string. > It could simply be the way strings are terminated on win32 systems. Or maybe some wide char/unicode problems? But I have to admit that I don't know anything about the Win32 API :-) > - Tk didn't seem to "see" the text, and if a widget needs to take over > the space held by the text, then it would do so. If you have a way to get the bounding box of the created text, then you can use it to set -width and -height of the widget manually. > - The text disappeared when the mainwindow was moved (I think any > <Configure> event had the same effect). So it could be fixed by using a <Configure> binding. === From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> Subject: Re: rotated text Newsgroups: comp.lang.perl.tk Date: Tue, 24 Feb 2004 05:10:22 GMT Ala Qumsieh wrote: > That reminds me. I found a way a while ago to draw rotated > text on Win32 using Win32::API, but it had some drawbacks: FWIW, here's some code that shows this. Needless to say, it runs only on Win32, and needs Win32::API. Just slide the Scale. Note that moving the window erases the text. Hope it helps inspire someone to come up with something useful :) --Ala #!perl -w use strict; use Tk; use Win32::API; my $angle = 0; # in degrees my $font_type = 'Times New Roman';#'Fixesys'; my $mw = new MainWindow; $mw->Scale(-command => \&printme, -from => 0, -to => 360, -label => 'Angle', -showvalue => 1, -variable => \$angle, -orient => 'horizontal', )->pack(qw/side bottom -fill x/); $mw->geometry("400x400"); # create the win32::api callbacks my $CreateFont = new Win32::API('gdi32' , 'CreateFont', [('N') x 13, 'P'], 'N'); my $SelectObject = new Win32::API('gdi32' , 'SelectObject', [qw/N N/], 'N'); my $DeleteObject = new Win32::API('gdi32' , 'DeleteObject', ['P'], 'I'); my $DrawText = new Win32::API('user32', 'DrawText', [qw/N P N P N/], 'N'); my $GetDC = new Win32::API('user32', 'GetDC', ['N'], 'N'); my $ExtTextOut = new Win32::API('gdi32' , 'ExtTextOut', [qw/N I I N P P I P/], 'I'); my $hwnd = eval($mw->id); MainLoop; sub printme { my $hdc = $GetDC->Call($hwnd); my $font = $CreateFont->Call(50, 0, $angle * 10, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, $font_type); my $old = $SelectObject->Call($hdc, $font); $ExtTextOut->Call( $hdc, 180, 180, 0, 0, "Perl/Tk", 7, 0 ); $SelectObject->Call($hdc, $old); $DeleteObject->Call($font); } === From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com> Subject: Re: rotated text Newsgroups: comp.lang.perl.tk Date: Tue, 24 Feb 2004 05:51:54 GMT $_@_.%_ wrote: > Wow thats some luvly code.. cant understand it, but nice. Do I sense a hint of sarcasm? :) > Here is the error it produces on Windows 2000 server. > The instruction at "0x01dc3ec1" referenced memory at > "0x00000000". > The memory could not be "read". > Click on OK to terminate the program > Click on CANCEL to debug the program Hmm .. works on my winXP box (WinXP Pro, Version 2002, Service Pack 1). I don't have any other win32 machines to test it .. sorry. And Microsoft complains that different Linux distributions are incompatible! Sheesh! ===