Subject: | Fix to make it work in Windows 7 (and probably Windows Vista too) |
Apply the diff to fix it.
Windows 7 doesn't allow read/write access to machine keys by default.
I also left the file names in the original case because Windows can mount
case sensitive file systems and there is no case in changing file names
into uppercase anyway.
Subject: | diff.txt |
--- NameToFile_010.pm Wed Jan 4 21:54:49 2006
+++ NameToFile.pm Mon Dec 24 20:18:00 2012
@@ -166,7 +166,8 @@
=cut
-use Win32::TieRegistry;
+use Win32::TieRegistry qw(:KEY_);
+use Carp qw(croak);
use Exporter;
use base qw(Exporter);
@@ -183,48 +184,47 @@
our $VERSION = 0.10;
BEGIN {
-#
-# the registry may store fonts in Windows NT or Windows
-#
- my @tmpfonts = sort keys %{$Registry->{'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts'}};
-
- @tmpfonts = sort keys %{$Registry->{'HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Fonts'}}
- unless scalar @tmpfonts;
-#
-# lowercase everything to simplify lookups
-#
- my $file;
-
- foreach (@tmpfonts) {
- $file = uc $Registry->{"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts$_"};
-#
-# only save truetypes
-#
- next unless ($file=~/\.ttf$/i);
- s/^\\+//;
- s/\s*\(TrueType\)//;
- $fontkeys{lc $_} = $file;
- push @fontnames, lc $_;
-#
-# check for bold or italic (or both)
-#
- s/\s+bold\b//i,
- s/\s+(italic|oblique)\b//i,
- s/\s+$//,
- $bold_italic_fonts{lc $_} = $file,
- next
- if (/\s+bold\b/i && /\s+(italic|oblique)\b/i);
-
- s/\s+bold\b//i,
- s/\s+$//,
- $bold_fonts{lc $_} = $file,
- next
- if /\s+bold\b/i;
-
- s/\s+(italic|oblique)\b//i,
- s/\s+$//,
- $italic_fonts{lc $_} = $file
- if /\s+(italic|oblique)\b/i;
+ $Registry->Delimiter('/');
+ # the registry may store fonts in 'Windows NT' or 'Windows'
+ foreach my $path (
+ 'HKEY_LOCAL_MACHINE/Software/Microsoft/Windows NT/CurrentVersion/Fonts',
+ 'HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Fonts',
+ ) {
+ if (my $r = $Registry->Open($path, {Access=>KEY_READ()})) {
+
+ # lowercase everything to simplify lookups
+ local $_;
+ foreach (sort keys %$r) {
+ my $file = $r->{$_};
+
+ # only save truetypes
+ next unless ($file=~/\.ttf$/i);
+ s/^\/+//;
+ s/\s*\(TrueType\)//;
+ $fontkeys{lc $_} = $file;
+ push @fontnames, lc $_;
+
+ # check for bold or italic (or both)
+ s/\s+bold\b//i,
+ s/\s+(?:italic|oblique)\b//i,
+ s/\s+$//,
+ $bold_italic_fonts{lc $_} = $file,
+ next
+ if (/\s+bold\b/i && /\s+(?:italic|oblique)\b/i);
+
+ s/\s+bold\b//i,
+ s/\s+$//,
+ $bold_fonts{lc $_} = $file,
+ next
+ if /\s+bold\b/i;
+
+ s/\s+(?:italic|oblique)\b//i,
+ s/\s+$//,
+ $italic_fonts{lc $_} = $file
+ if /\s+(?:italic|oblique)\b/i;
+ }
+ last;
+ }
}
}