Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:GA
ghostscript-cjk
acroread-cidfont-config
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File acroread-cidfont-config of Package ghostscript-cjk
#!/usr/bin/perl -w # # Copyright (c) 2004 SuSE Linux AG, Nuernberg, Germany. All rights reserved. # # Author: Mike Fabian <mfabian@suse.de>, 2004 # =head1 NAME acroread-cidfont-config - configures CID keyed fonts for use with acroread =head1 SYNOPSIS acroread-cidfont-config [B<OPTION>]... =head1 DESCRIPTION configures CID keyed fonts for use with acroread =head1 OPTIONS =over 4 =item B<-v>, B<--verbose> print some messages to standard output. =item B<-f>, B<--force> overwrite existing files. =item B<-r>, B<--remove-fakes> remove faked CID keyed fonts again. =back =head1 AUTHOR Mike Fabian <I<mfabian@suse.de>>. =cut use strict; use English; use Getopt::Long; use File::Find; my $OPT_VERBOSE; my $OPT_FORCE; my $OPT_REMOVE_FAKES; my @directories = ("/usr/share/ghostscript", "/usr/lib/Acrobat", "/usr/lib/Adobe"); my $cmap_dir = ""; my $cidfont_dir = ""; my $acrobat_dir = ""; sub wanted { return unless -d; if (m@CMap@ && ! $cmap_dir) { $cmap_dir = $File::Find::name if ($File::Find::dir =~ m@/usr/share/ghostscript/.*@); } if (m@CIDFont@ && ! $cidfont_dir) { $cidfont_dir = $File::Find::name if ($File::Find::dir =~ m@/usr/share/ghostscript/.*@); } if (m@Font@ && ! $acrobat_dir) { $acrobat_dir = $File::Find::name if ($File::Find::dir =~ m@/usr/lib/A.*@); } } my %cidfont_replacements = ( "HYGoThic-Medium-Acro" , "MunhwaGothic-Regular", "HYSMyeongJo-Medium-Acro" , "Munhwa-Regular", "HeiseiKakuGo-W5-Acro" , "WadaGo-Bold", "HGPSoeiKakugothicUB" , "WadaGo-Bold", "MS-Gothic" , "WadaGo-Bold", "HGGothicB" , "WadaGo-Bold", "HGPGothicB" , "WadaGo-Bold", "HeiseiMin-W3-Acro" , "WadaMin-Bold", "MS-Mincho" , "WadaMin-Bold", "HGMinchoL" , "WadaMin-Bold", "HGPMinchoL" , "WadaMin-Bold", "MHei-Medium-Acro" , "MOEKai-Regular", "MSung-Light-Acro" , "MOESung-Regular", "ShanHeiSun-Light" , "MOESung-Regular", "STSong-Light-Acro" , "unfortunately-no-replacement-available" ); ###################################################################### sub create_cmap_symlinks { my $cwd; chomp ($cwd = `pwd`); chdir $cmap_dir || die "Can't cd to $cmap_dir: $!\n"; for my $file (glob ("*")) { if ($OPT_VERBOSE) { printf "symlink (\"$cmap_dir/$file\", \"$acrobat_dir/$file.cmap\")\n"; } symlink ("$cmap_dir/$file", "$acrobat_dir/$file.cmap"); } chdir $cwd ||die "Can't cd to $cwd: $!\n"; } sub create_CMap_upr { if ( ! -f "$acrobat_dir/CMap.upr" || $OPT_FORCE ) { if ($OPT_VERBOSE) { print "generating $acrobat_dir/CMap.upr ...\n"; } my $cwd; chomp ($cwd = `pwd`); chdir $acrobat_dir || die "Can't cd to $acrobat_dir: $!\n"; open (CMAPUPR, ">CMap.upr") || die "can't open file $acrobat_dir/CMap.upr for writing: $!"; printf CMAPUPR "PS-Resources-1.0\n"; printf CMAPUPR "CMap\n"; printf CMAPUPR ".\n"; printf CMAPUPR "CMap\n"; for my $map (glob ("*.cmap")) { $map =~ /(.*).cmap/; printf CMAPUPR "$1=$map\n"; } printf CMAPUPR ".\n"; close (CMAPUPR); chdir $cwd || die "Can't cd to $cwd: $!\n"; } elsif ($OPT_VERBOSE) { print "$acrobat_dir/CMap.upr already exists, skipping ...\n"; } } my $fake_tag = "faked by acroread-cidfont-config"; sub fake_cidfonts { for my $font (keys %cidfont_replacements) { if ( ! -f "$acrobat_dir/$font" || $OPT_FORCE) { if ( -f "$cidfont_dir/$cidfont_replacements{$font}" ) { my_system ("cp $cidfont_dir/$cidfont_replacements{$font} $acrobat_dir/$font"); my_system ("perl -pi -e \"s/$cidfont_replacements{$font}/$font/\" $acrobat_dir/$font"); my_system ("perl -pi -e \"s/(%%Title:.*)/\\1 ($fake_tag)/\" $acrobat_dir/$font"); } elsif ($OPT_VERBOSE) { print "Replacement for $font does not exist, skipping ...\n"; } } elsif ($OPT_VERBOSE) { print "$acrobat_dir/$font already exists, skipping ...\n"; } } } sub remove_fakes { my $cwd; chomp ($cwd = `pwd`); chdir $acrobat_dir || die "Can't cd to $acrobat_dir: $!\n"; for my $file (glob ("*")) { if (! my_system ("grep -q \"$fake_tag\" $file")) { if ($OPT_VERBOSE) { print "$file is faked, remove it\n"; } unlink($file); } } chdir $cwd || die "Can't cd to $cwd: $!\n"; } sub search_executable { for my $file (@_) { if (-x $file) { return $file; } } return ""; } sub search_directory { for my $dir (@_) { if (-d $dir) { return $dir; } } return ""; } sub my_system { my ($command) = @_; if ($OPT_VERBOSE) { print "executing: $command\n"; } return system ($command); } sub usage { print "Usage: acroread-cidfont-config [--verbose|v] [--force|v]\n"; exit 1; } ###################################################################### # check if we are started as root # only one of UID and USER must be set correctly # Process command line options my %opt; unless (GetOptions(\%opt, 'verbose|v', \$OPT_VERBOSE, 'force|f', \$OPT_FORCE, 'remove-fakes|r', \$OPT_REMOVE_FAKES, )) { &usage(); exit 1; } if ($UID != 0 && $ENV{USER} !~ /root/) { print "You must be root to start $0\n"; exit 1; } no warnings; find(\&wanted, @directories); use warnings; if (! -d $cmap_dir || ! -d $cidfont_dir || ! -d $acrobat_dir) { if ($OPT_VERBOSE) { printf "a required directory is missing.\n"; } exit 1; } if ($OPT_REMOVE_FAKES) { remove_fakes(); exit 0; } create_cmap_symlinks (); create_CMap_upr (); fake_cidfonts (); exit 0;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor