On Wed, Mar 06, 2002 at 11:05:33PM +0100, Danny Tholen wrote:
> 
> Ok, after dam's miserable attempt to fix it (just joking) here is my way:
> 
> it seems that the latest fix uses this line to rename to ttf fonts:
> system ("cd $drakfont_dir/tmp/tmp ; for i in *.TTF; do mv -f $i `basename $i 
>.TTF`.ttf; done");
> 
> For some reason this does not work (maybe because of backticks or $?) in perl, but 
>the next one does:
> system ('cd '.$drakfont_dir.'/tmp/tmp ; for i in *.TTF; do mv -f $i `basename $i 
>.TTF`.ttf; done');
> 
> 
> Now, lets hope nobody has fonts named ArIal.TtF (because I do not know how to do 
>that:)
> 
> 
> Next follows a diff for drakfont (drakxtools-1.1.7-89mdk):
> 
> 
> --- drakfont    Sun Mar  3 21:59:49 2002
> +++ drakfont.new        Wed Mar  6 23:11:43 2002
> @@ -351,8 +351,8 @@
>         }
>         $interactive and progress($pbar1, 0.01, _("done"));
>         $interactive and progress($pbar2, 0.10, _("True Type fonts installation"));
> -
> -       system ("cd $drakfont_dir/tmp/tmp ; for i in *.TTF; do mv -f $i `basename $i 
>.TTF`.ttf; done");
> +
> +       system ('cd '.$drakfont_dir.'/tmp/tmp ; for i in *.TTF; do mv -f $i 
>`basename $i .TTF`.ttf; done');
>         system ("cd $drakfont_dir/tmp/tmp  && cp *.ttf ../../ttf");
>         $interactive and progress($pbar2, 0.20, _("please wait during ttmkfdir..."));
>         system ("cd $drakfont_dir/ttf && $ttmkfdir > fonts.dir" );

A better question is why are you doing all this work in a shell when
you've already got a perl process running.  Seems so silly.

use DirHandle; 
my $drakfont_dir_handle = new DirHandle "$drakfont_dir_handle/tmp/tmp";
if (defined $drakfont_dir_handle) {
  my $curname;
  while (defined($curname = $drakfont_dir_handle->read)) {
    my $newname = $curname;
    if ($curname !~ /\.ttf$/ && $curname !~ /\.ttf$/i) {
      $newname =~ s/\.ttf$/\.ttf/i;
      rename $curname, $newname || warn "Couldn't rename font $curname to
$newname: $!";
    }
  }
  undef $drakfont_dir_handle;
} else {
  warn "Unable open directory handle to be able to find fonts that need
renaming\n";
}

While I didn't test this in drakfont I did test it in a quick and dirty
standalone script.  And DirHandle is included in the standard perl
package. :)

I know it's longer but it handles any case combination of .ttf cleanly.

-- 
Ben Reser <[EMAIL PROTECTED]>
http://ben.reser.org

What difference does it make to the dead, the orphans, and the homeless,
whether the mad destruction is wrought under the name of totalitarianism
or the holy name of liberty and democracy? - Ghandi

Reply via email to