File Coverage

blib/lib/Xorg/XLFD.pm
Criterion Covered Total %
statement 12 55 21.8
branch 0 28 0.0
condition 0 3 0.0
subroutine 4 5 80.0
pod 1 1 100.0
total 17 92 18.4


line stmt bran cond sub pod time code
1             package Xorg::XLFD;
2 1     1   66896 use strict;
  1         3  
  1         53  
3              
4             BEGIN {
5 1     1   7 use Exporter;
  1         2  
  1         249  
6 1     1   6 use vars qw($VERSION @ISA @EXPORT_OK);
  1         7  
  1         128  
7              
8 1     1   2 $VERSION = '0.128';
9              
10 1         16 @ISA = qw(Exporter);
11              
12 1         2144 @EXPORT_OK = qw(get_xlfd);
13              
14             };
15              
16             sub get_xlfd {
17 0     0 1   my $fam = shift; # fixed
18 0           my %fonts;
19              
20 0 0         open(my $fh, '-|', 'xlsfonts') or croak("xlsfonts: $!\n");
21              
22 0           while(<$fh>) {
23 0           chomp;
24 0           $_ =~ s/^-//;
25 0           my($foundary, $family, $weight, $slant, $set_width, $pixels, $tenths,
26             $h_dpi, $v_dpi, $spacing, $avg_width, $charset)
27             = split(/--?/, $_);
28              
29 0 0 0       if( ($family =~ /^\d+$/m) or ($family eq '') ) {
30 0           next;
31             }
32              
33 0           push(@{$fonts{family}->{$family}->{weight}}, $weight)
  0            
34 0 0         unless $weight ~~ @{$fonts{family}->{$family}->{weight}};
35              
36 0           push(@{$fonts{family}->{$family}->{width}}, $avg_width)
  0            
37 0 0         unless $avg_width ~~ @{$fonts{family}->{$family}->{width}};
38              
39 0           push(@{$fonts{family}->{$family}->{vert_dpi}}, $v_dpi)
  0            
40 0 0         unless $v_dpi ~~ @{$fonts{family}->{$family}->{vert_dpi}};
41              
42 0           push(@{$fonts{family}->{$family}->{horiz_dpi}}, $h_dpi)
  0            
43 0 0         unless $h_dpi ~~ @{$fonts{family}->{$family}->{horiz_dpi}};
44              
45 0           push(@{$fonts{family}->{$family}->{tenths}}, $tenths)
  0            
46 0 0         unless $tenths ~~ @{$fonts{family}->{$family}->{tenths}};
47              
48 0           push(@{$fonts{family}->{$family}->{spacing}}, $spacing)
  0            
49 0 0         unless $spacing ~~ @{$fonts{family}->{$family}->{spacing}};
50              
51 0           push(@{$fonts{family}->{$family}->{slant}}, $slant)
  0            
52 0 0         unless $slant ~~ @{$fonts{family}->{$family}->{slant}};
53              
54 0           push(@{$fonts{family}->{$family}->{'set width'}}, $set_width)
  0            
55 0 0         unless $set_width ~~ @{$fonts{family}->{$family}->{'set width'}};
56              
57 0           push(@{$fonts{family}->{$family}->{pixels}}, $pixels)
  0            
58 0 0         unless $pixels ~~ @{$fonts{family}->{$family}->{pixels}};
59              
60 0           push(@{$fonts{family}->{$family}->{charset}}, $charset)
  0            
61 0 0         unless $charset ~~ @{$fonts{family}->{$family}->{charset}};
62              
63 0           push(@{$fonts{family}->{$family}->{foundary}}, $foundary)
  0            
64 0 0         unless $foundary ~~ @{$fonts{family}->{$family}->{foundary}};
65              
66             }
67 0 0         return (exists($fonts{family}{$fam}))
68             ? $fonts{family}{$fam}
69             : \%fonts
70             ;
71             }
72              
73              
74             1;
75              
76              
77             __END__