X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/e316fc14bef26f958937aec0e6854b61f71a3b34..09dded3d8606e8e4406fffcf477ceb4a1c97fee2:/librarian/font-optimizer/ext/Font-TTF/lib/Font/TTF/Win32.pm diff --git a/librarian/font-optimizer/ext/Font-TTF/lib/Font/TTF/Win32.pm b/librarian/font-optimizer/ext/Font-TTF/lib/Font/TTF/Win32.pm new file mode 100644 index 0000000..bb8886e --- /dev/null +++ b/librarian/font-optimizer/ext/Font-TTF/lib/Font/TTF/Win32.pm @@ -0,0 +1,33 @@ +package Font::TTF::Win32; + +# use strict; +# use vars qw($HKEY_LOCAL_MACHINE); + +use Win32::Registry; +use Win32; +use File::Spec; +use Font::TTF::Font; + + +sub findfonts +{ + my ($sub) = @_; + my ($font_key) = 'SOFTWARE\Microsoft\Windows' . (Win32::IsWinNT() ? ' NT' : '') . '\CurrentVersion\Fonts'; + my ($regFont, $list, $l, $font, $file); + +# get entry from registry for a font of this name + $::HKEY_LOCAL_MACHINE->Open($font_key, $regFont); + $regFont->GetValues($list); + + foreach $l (sort keys %{$list}) + { + my ($fname) = $list->{$l}[0]; + next unless ($fname =~ s/\(TrueType\)$//o); + $file = File::Spec->rel2abs($list->{$l}[2], "$ENV{'windir'}/fonts"); + $font = Font::TTF::Font->open($file) || next; + &{$sub}($font, $fname); + $font->release; + } +} + +1;