diff options
| author | Andreas Brachold <vdr07@deltab.de> | 2009-11-28 12:20:03 +0000 |
|---|---|---|
| committer | Andreas Brachold <vdr07@deltab.de> | 2009-11-28 12:20:03 +0000 |
| commit | 88e0eef1e7bb44b12037c05bca9551586bd6e7c0 (patch) | |
| tree | 6dbb5f2309d101cacc78640047a6b3a33b39ee01 /lib | |
| parent | b44cff2ff83ed4e2743ecc7f4c1e03ece97bbaf9 (diff) | |
| download | xxv-88e0eef1e7bb44b12037c05bca9551586bd6e7c0.tar.gz xxv-88e0eef1e7bb44b12037c05bca9551586bd6e7c0.tar.bz2 | |
* GRAB/STATUS - select font by real names (need perl modul Font::TTF::Font)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Tools.pm | 37 | ||||
| -rw-r--r-- | lib/XXV/MODULES/GRAB.pm | 33 | ||||
| -rw-r--r-- | lib/XXV/MODULES/STATUS.pm | 28 |
3 files changed, 43 insertions, 55 deletions
diff --git a/lib/Tools.pm b/lib/Tools.pm index 5428aa2..10b715a 100644 --- a/lib/Tools.pm +++ b/lib/Tools.pm @@ -13,6 +13,8 @@ $Data::Dumper::Indent = 1; #$Data::Dumper::Maxdepth = 2; use IO::File; +use File::Basename; +use File::Find; use Socket; use Time::HiRes qw( gettimeofday ); use POSIX qw(strftime); @@ -34,7 +36,7 @@ use constant FRAMESPERSECOND => 25; &deleteDir &getip &convert &int &entities &reentities &bench &fmttime &getDataByTable &getDataById &getDataBySearch &getDataByFields &touch &url &con_err &con_msg &text2frame &frame2hms &gettext &setcharset &resolv_symlink - &connectDB + &connectDB &findttf ); @@ -839,4 +841,37 @@ sub connectDB { return $dbh; } +# ------------------ +# Find usable fonts for graphical outputs +sub findttf +{ + my $directory = shift || return error('No fonts directory defined!'); + my $found; + my $font; + eval 'use Font::TTF::Font'; + unless($@) { + $font = 1; + } + find({ wanted => sub{ + if($File::Find::name =~ /\.ttf$/sig) { + my $f = basename($File::Find::name); + my $fontname = $f; + if($font) { + $fontname = Font::TTF::Font->open($f) || $f; + $fontname = $fontname->{name} || $f if ref $fontname; + $fontname = $fontname->read->find_name(4) || $f if ref $fontname; + } + push(@{$found},[$fontname,$f]); + } + }, + follow => 1, + follow_skip => 2, + }, + $directory + ); + error "Couldn't find useful font at : $directory" + if(scalar $found == 0); + return $found; +} + 1; diff --git a/lib/XXV/MODULES/GRAB.pm b/lib/XXV/MODULES/GRAB.pm index 8895535..6c66dda 100644 --- a/lib/XXV/MODULES/GRAB.pm +++ b/lib/XXV/MODULES/GRAB.pm @@ -2,8 +2,6 @@ package XXV::MODULES::GRAB; use strict; use Tools; -use File::Basename; -use File::Find; # This module method must exist for XXV # ------------------ @@ -13,9 +11,10 @@ sub module { my $args = { Name => 'GRAB', Prereq => { - 'GD' => 'image manipulation routines', - 'Template' => 'Front-end module to the Template Toolkit ', - 'MIME::Base64' => 'Encoding and decoding of base64 strings' + 'GD' => 'image manipulation routines' + ,'Template' => 'Front-end module to the Template Toolkit ' + ,'MIME::Base64' => 'Encoding and decoding of base64 strings' + ,'Font::TTF::Font' => 'String table for a TTF font' }, Description => gettext('This module grab a picture from video output.'), Version => (split(/ /, '$Revision$'))[1], @@ -78,7 +77,7 @@ sub module { description => gettext('TrueType font to draw overlay text'), default => 'VeraIt.ttf', type => 'list', - choices => $self->findttf, + choices => Tools::findttf($self->{paths}->{FONTPATH}) }, imgfontsize => { description => gettext('Font size to draw image text (only for ttf font!).'), @@ -367,26 +366,4 @@ sub _noise_rect { return; } -# ------------------ -sub findttf -# ------------------ -{ - my $self = shift || return error('No object defined!'); - my $found; - find({ wanted => sub{ - if($File::Find::name =~ /\.ttf$/sig) { - my $l = basename($File::Find::name); - push(@{$found},[$l,$l]); - } - }, - follow => 1, - follow_skip => 2, - }, - $self->{paths}->{FONTPATH} - ); - error "Couldn't find useful font at : ", $self->{paths}->{FONTPATH} - if(scalar $found == 0); - return $found; -} - 1; diff --git a/lib/XXV/MODULES/STATUS.pm b/lib/XXV/MODULES/STATUS.pm index d40616b..1901792 100644 --- a/lib/XXV/MODULES/STATUS.pm +++ b/lib/XXV/MODULES/STATUS.pm @@ -4,8 +4,6 @@ use strict; use Tools; use Socket; use Sys::Hostname; -use File::Basename; -use File::Find; # This module method must exist for XXV # ------------------ @@ -15,7 +13,7 @@ sub module { my $args = { Name => 'STATUS', Prereq => { - # 'Perl::Module' => 'Description', + 'Font::TTF::Font' => 'String table for a TTF font' }, Description => gettext('This module analyzes your system and displays the result.'), Version => (split(/ /, '$Revision$'))[1], @@ -56,7 +54,7 @@ sub module { description => gettext('TrueType font to draw overlay text'), default => 'Vera.ttf', type => 'list', - choices => $obj->findttf, + choices => Tools::findttf($obj->{paths}->{FONTPATH}) }, graphic => { description => gettext('Show collected data as diagram?'), @@ -761,28 +759,6 @@ sub videoMounts { } # ------------------ -sub findttf -# ------------------ -{ - my $obj = shift || return error('No object defined!'); - my $found; - find({ wanted => sub{ - if($File::Find::name =~ /\.ttf$/sig) { - my $l = basename($File::Find::name); - push(@{$found},[$l,$l]); - } - }, - follow => 1, - follow_skip => 2, - }, - $obj->{paths}->{FONTPATH} - ); - error "Couldn't find useful font at : $obj->{paths}->{FONTPATH}" - if(scalar $found == 0); - return $found; -} - -# ------------------ sub watchDog { # ------------------ my $obj = shift || return error('No object defined!'); |
