| 1 | #======================================================================= | ||
| 2 | # ____ ____ _____ _ ____ ___ ____ | ||
| 3 | # | _ \| _ \| ___| _ _ / \ | _ \_ _| |___ \ | ||
| 4 | # | |_) | | | | |_ (_) (_) / _ \ | |_) | | __) | | ||
| 5 | # | __/| |_| | _| _ _ / ___ \| __/| | / __/ | ||
| 6 | # |_| |____/|_| (_) (_) /_/ \_\_| |___| |_____| | ||
| 7 | # | ||
| 8 | # A Perl Module Chain to faciliate the Creation and Modification | ||
| 9 | # of High-Quality "Portable Document Format (PDF)" Files. | ||
| 10 | # | ||
| 11 | # Copyright 1999-2005 Alfred Reibenschuh <areibens@cpan.org>. | ||
| 12 | # | ||
| 13 | #======================================================================= | ||
| 14 | # | ||
| 15 | # This library is free software; you can redistribute it and/or | ||
| 16 | # modify it under the terms of the GNU Lesser General Public | ||
| 17 | # License as published by the Free Software Foundation; either | ||
| 18 | # version 2 of the License, or (at your option) any later version. | ||
| 19 | # | ||
| 20 | # This library is distributed in the hope that it will be useful, | ||
| 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 23 | # Lesser General Public License for more details. | ||
| 24 | # | ||
| 25 | # You should have received a copy of the GNU Lesser General Public | ||
| 26 | # License along with this library; if not, write to the | ||
| 27 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 28 | # Boston, MA 02111-1307, USA. | ||
| 29 | # | ||
| 30 | # $Id: Win32.pm,v 2.0 2005/11/16 02:16:00 areibens Exp $ | ||
| 31 | # | ||
| 32 | #======================================================================= | ||
| 33 | |||
| 34 | package PDF::API3::Compat::API2::Win32; | ||
| 35 | |||
| 36 | use vars qw($VERSION); | ||
| 37 | ( $VERSION ) = '$Revision: 2.0 $' =~ /Revision: (\S+)\s/; # $Date: 2005/11/16 02:16:00 $ | ||
| 38 | |||
| 39 | no warnings qw[ deprecated recursion uninitialized ]; | ||
| 40 | |||
| 41 | package PDF::API3::Compat::API2; | ||
| 42 | |||
| 43 | use vars qw( $wf ); | ||
| 44 | use Win32::TieRegistry; | ||
| 45 | |||
| 46 | no warnings qw[ recursion uninitialized ]; | ||
| 47 | |||
| 48 | $wf={}; | ||
| 49 | |||
| 50 | $Registry->Delimiter("/"); | ||
| 51 | |||
| 52 | my $fontdir = $Registry->{"HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders"}->{Fonts}; | ||
| 53 | |||
| 54 | my $subKey = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Fonts/"}; | ||
| 55 | |||
| 56 | foreach my $k (sort keys %{$subKey}) { | ||
| 57 | next unless($subKey->{$k}=~/\.[ot]tf$/i); | ||
| 58 | my $kk=lc($k); | ||
| 59 | $kk=~s|^/||; | ||
| 60 | $kk=~s|\s+\(truetype\).*$||g; | ||
| 61 | $kk=~s|\s+\(opentype\).*$||g; | ||
| 62 | $kk=~s/[^a-z0-9]+//g; | ||
| 63 | |||
| 64 | $wf->{$kk}={}; | ||
| 65 | |||
| 66 | $wf->{$kk}->{display}=$k; | ||
| 67 | $wf->{$kk}->{display}=~s|^/||; | ||
| 68 | |||
| 69 | if(-e "$fontdir/$subKey->{$k}") { | ||
| 70 | $wf->{$kk}->{ttfile}="$fontdir/$subKey->{$k}"; | ||
| 71 | } else { | ||
| 72 | $wf->{$kk}->{ttfile}=$subKey->{$k}; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | |||
| 76 | $subKey = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Type 1 Installer/Type 1 Fonts/"}; | ||
| 77 | |||
| 78 | foreach my $k (sort keys %{$subKey}) { | ||
| 79 | my $kk=lc($k); | ||
| 80 | $kk=~s|^/||; | ||
| 81 | $kk=~s/[^a-z0-9]+//g; | ||
| 82 | |||
| 83 | $wf->{$kk}={}; | ||
| 84 | |||
| 85 | $wf->{$kk}->{display}=$k; | ||
| 86 | $wf->{$kk}->{display}=~s|^/||; | ||
| 87 | |||
| 88 | my $t; | ||
| 89 | ($t,$wf->{$kk}->{pfmfile},$wf->{$kk}->{pfbfile})=split(/\0/,$subKey->{$k}); | ||
| 90 | |||
| 91 | if(-e "$fontdir/$wf->{$kk}->{pfmfile}") { | ||
| 92 | $wf->{$kk}->{pfmfile}="$fontdir/".$wf->{$kk}->{pfmfile}; | ||
| 93 | $wf->{$kk}->{pfbfile}="$fontdir/".$wf->{$kk}->{pfbfile}; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | sub enumwinfonts { | ||
| 98 | my $self=shift @_; | ||
| 99 | return(map { $_ => $wf->{$_}->{display} } keys %{$wf}); | ||
| 100 | } | ||
| 101 | |||
| 102 | sub winfont { | ||
| 103 | my $self=shift @_; | ||
| 104 | my $key=lc(shift @_); | ||
| 105 | $key=~s/[^a-z0-9]+//g; | ||
| 106 | |||
| 107 | return(undef) unless(defined $wf && defined $wf->{$key}); | ||
| 108 | |||
| 109 | if(defined $wf->{$key}->{ttfile}) { | ||
| 110 | return($self->ttfont($wf->{$key}->{ttfile}, @_)); | ||
| 111 | } else { | ||
| 112 | return($self->psfont($wf->{$key}->{pfbfile}, -pfmfile => $wf->{$key}->{pfmfile}, @_)); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | 1; | ||
| 117 | |||
| 118 | __END__ |