Skip Menu |
 

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 42043
Status: open
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: bitcardcrowell08 [...] lightandmatter.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 804.028
Fixed in: (no value)



Subject: font regression: asking for bold causes size to be ignored
Download (untitled) / with headers
text/plain 1.3k
In older versions of Perl/Tk, a font could be specified like this, and it would work: -font=>[-size=>'32',-weight=>'bold'] In this version, the fonts seem to have been upgraded to look much better (yay!), but along the way there seems to have been a regression, because including the -weight parameter causes the -size parameter to be ignored in many cases. I'm guessing that what's happening is that if Perl/Tk can't find a font with both the required size *and* the required weight, it ignores both the size and the weight. This will break lots of preexisting code. The code sample attached demonstrates the bug on my system; the label that's supposed to be 32-point bold is actually displayed in a smaller font, not 32 point. Reproducing this bug may depend on what fonts you have installed on your system. $ perl --version This is perl, v5.10.0 built for x86_64-linux-gnu-thread-multi Copyright 1987-2007, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. $ uname -a Linux rintintin 2.6.27-9-generic #1 SMP Thu Nov 20 22:15:32 UTC 2008 x86_64 GNU/Linux
Subject: font_bug.pl
Download font_bug.pl
text/x-perl 334b
#!/usr/local/bin/perl use Tk; # Main Window my $mw = new MainWindow; my $label = $mw -> Label(-text=>"32-point bold",-font=>[-weight=>'bold']) -> pack(); my $label = $mw -> Label(-text=>"32-point, no bold",-font=>[-size=>'32']) -> pack(); my $button = $mw -> Button(-text => "Quit", -command => sub { exit }) -> pack(); MainLoop;
Download (untitled) / with headers
text/plain 846b
It now occurs to me that if you specify more than one attribute for the font (e.g., both size and bold), and Tk is unable to satisfy both simultaneously, it's not a trivial question which one it should try to satisfy. However, the behavior of this bug seems to be that if it can't simultaneously satisfy both, it ignores both, rather than picking one to satisfy. So it seems to me that the best possible fix would be: Find some way to simultaneously satisfy both the size and the weight, e.g., by using the scaling facilities of an underlying library like Cairo. Or if that's too hard: Prioritize the font attributes. If it's impossible to satisfy all the requested attributes simultaneously, throw away the lowest-priority attribute and try again. Continue until able to satisfy them all. I think size should be higher in priority than weight.
Download (untitled) / with headers
text/plain 1.9k
On Tue Dec 30 14:24:34 2008, bcrowell3 wrote: Show quoted text
> In older versions of Perl/Tk, a font could be specified like this, and > it would work: > > -font=>[-size=>'32',-weight=>'bold'] > > In this version, the fonts seem to have been upgraded to look much > better (yay!), but along the way there seems to have been a regression, > because including the -weight parameter causes the -size parameter to be > ignored in many cases. I'm guessing that what's happening is that if > Perl/Tk can't find a font with both the required size *and* the required > weight, it ignores both the size and the weight. This will break lots of > preexisting code. > > The code sample attached demonstrates the bug on my system; the label > that's supposed to be 32-point bold is actually displayed in a smaller > font, not 32 point. Reproducing this bug may depend on what fonts you > have installed on your system. > > $ perl --version > > This is perl, v5.10.0 built for x86_64-linux-gnu-thread-multi > > Copyright 1987-2007, Larry Wall > > Perl may be copied only under the terms of either the Artistic License > or the > GNU General Public License, which may be found in the Perl 5 source kit. > > Complete documentation for Perl, including FAQ lists, should be found on > this system using "man perl" or "perldoc perl". If you have access to the > Internet, point your browser at http://www.perl.org/, the Perl Home Page. > > $ uname -a > Linux rintintin 2.6.27-9-generic #1 SMP Thu Nov 20 22:15:32 UTC 2008 > x86_64 GNU/Linux
I can reproduce the problem, and I created a test case in the Perl/Tk subversion repository based on your script. If you need a workaround then you can fallback to Tcl-ish stringy font specifications, that is something like "{sans serif} 32 bold". This seems to work with the freetype variant of Perl/Tk. So basically the internals may cope when one specifies both size and weight, but somehow it's lost in the array form of -font. Regards, Slaven


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.