I think you will run into difficulty trying to declare a default system wide font in .Xdefaults, but you can easily make a default font in a Tk program with a single line. Notice the canvas dosn't pick up on the default font, but other widgets do. I don't run windows, but I would be interested to hear your report on whether the program below looks the same on linux and windows.
and a full program to demonstrate# set a default font for all widgets $mw->optionAdd('*font', 'Arial 24');
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow(-bg =>'black'); # set a default font $mw->optionAdd('*font', 'Arial 24'); # a useful way of tagging fonts for special use $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=> 38 ); # will use default font my $menubar = $mw->Menu(-type => 'menubar'); $mw->configure(-menu => $menubar); my $menu = $menubar->cascade(-label => '~File'); $menu->command(-label => '~New'); $menu->command(-label => '~Open'); $mw->Button(-text => 'test this font', -bg=>'white')->pack; $mw->Label(-text => 'test this font', -bg=>'lightyellow')->pack; my $text = $mw->Text(-bg=>'white', -height => 4, -width =>20)->pack; $text->insert('0.0','test this font'); my $canvas = $mw->Canvas(-bg=>'lightgreen')->pack; #make a special font my $font = $mw->Font(-family=> 'Arial', -size => 18); # will use default font $canvas->createText( 0, 0, -anchor => 'nw', -text => 'test this font', ); # special font $canvas->createText( 0, 50, -anchor => 'nw', -text => 'test this font', -font => $font, ); # tagged font $canvas->createText( 0, 100, -anchor => 'nw', -text => 'test this font', -font => 'big', ); MainLoop;
In reply to Re: Perl/Tk Windows fonts for Linux?
by zentara
in thread Perl/Tk Windows fonts for Linux?
by tlhackque
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |