Perl/tk sans-serif font missing in Linux

Viewed 145

I have a perl/tk script that uses a canvas with text. A while back the font of the text changed alone: no more sans-serif! Probably some update/upgrade messed up my fonts, but they should be there somewhere. I only found this problem in perl/tk scripts.

I downloaded a small perl script that shows the installed fonts, and indeed no sans-serif appears. In fact, only 30 or so fonts appear. The command xlsfonts gives me more than 1600 fonts, yet xfontsel only shows these 30 font families.

How did the sans font disappear, and how do I restore/install back missing fonts?

This is the script I used to see the fonts:

#!/usr/bin/perl

use Tk;
use Tk::BrowseEntry;
use strict;

my $mw = MainWindow->new(-title => 'Font Viewer');
my $f = $mw->Frame->pack(-side => 'top');

my $family = 'Courier';
my $be = $f->BrowseEntry(-label => 'Family:', -variable => \$family,
  -browsecmd => \&apply_font)->pack(-fill => 'x', -side => 'left');
$be->insert('end', sort $mw->fontFamilies);

my $size = 24;
my $bentry = $f->BrowseEntry(-label => 'Size:', -variable => \$size,
  -browsecmd => \&apply_font)->pack(-side => 'left');
$bentry->insert('end', (3 .. 32));

my $weight = 'normal';
$f->Checkbutton(-onvalue => 'bold', -offvalue => 'normal',
  -text => 'Weight', -variable => \$weight,
  -command => \&apply_font)->pack(-side => 'left');

my $slant = 'roman';
$f->Checkbutton(-onvalue => 'italic', -offvalue => 'roman',
  -text => 'Slant', -variable => \$slant,
  -command => \&apply_font)->pack(-side => 'left');

my $underline = 0;
$f->Checkbutton(-text => 'Underline', -variable => \$underline,
  -command => \&apply_font)->pack(-side => 'left');

my $overstrike = 0;
$f->Checkbutton(-text => 'Overstrike', -variable => \$overstrike,
  -command => \&apply_font)->pack(-side => 'left');

my $stext = 'Sample Text';
my $sample = $mw->Entry(-textvariable => \$stext)->pack(-fill => 'x');

&apply_font;

MainLoop;

sub apply_font {
  # Specify all options for font in an anonymous array
  $sample->configure(-font =>
    [-family => $family,
     -size => $size,
     -weight => $weight,
     -slant => $slant,
     -underline => $underline,
     -overstrike => $overstrike]);
}
1 Answers

In some of the last updates this has been fixed. Sans fonts are back.

Related