use strict; use warnings; use Tk; use Tk::Text; use Tk::Font; use Data::Dumper; # Create pTk text window... my $mw = MainWindow->new(-title => 'Text Font'); my $txt = $mw->Scrolled('Text')->pack(-fill => 'x', -side => 'left'); # Get Current font... my $currfont = $txt->cget(-font); # Create new font by cloning & modifying current font... my $boldfont= $currfont->Clone(-weight=>'bold'); # configure new tag ('bold') causing tagged characters to use the new bold font... $txt->tagConfigure('bold', -font => $boldfont); # Insert some text that is not tagged as bold... $txt->insert('end', "========================\n"); $txt->insert('end', "Default font requested:\n" . Dumper($currfont)); $txt->insert('end', "\nDefault font chosen:\n" . Dumper($currfont->actual)); # Insert some text that is tagged as bold... $txt->insert('end', "========================\n"); $txt->insert('end', "Bold font requested:\n" . Dumper($boldfont), ['bold']); $txt->insert('end', "\nBold font chosen:\n" . Dumper($boldfont->actual), ['bold']); MainLoop;