~ubuntu-branches/ubuntu/raring/grace/raring

« back to all changes in this revision

Viewing changes to debian/update-grace-fonts

  • Committer: Bazaar Package Importer
  • Author(s): Nicholas Breen
  • Date: 2010-06-06 14:36:06 UTC
  • mfrom: (4.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100606143606-g8rdx6m4wyg3xx8l
Tags: 1:5.1.22-7
* Replace defoma font management with new /usr/sbin/update-grace-fonts
  trigger.  Many thanks to Kenshi Muto for the implementation.
  (Closes: #542335, #583956, #583964)
  - README.Debian: Update description of font handling, eliminate all
    references to defoma.
  - control: Depends -= defoma, += fontconfig.
* grace.preinst, grace.postinst: Additionally remove code only needed for
  upgrades from truly antique (pre-oldstable) releases.
* patches/nonlinear_extended.diff: Add menu entry for Doniach-Sunjic peak
  fitting.  (Closes: #583966)
* Backed out subscript-superscript-scale.diff pending coordination with
  upstream, to avoid distro-specific incompatibilities.
* compat: Increment to debhelper v7.
* Convert to source format 3.0 (quilt).  Replace uuencoded icons with 
  their decoded PNG forms; clean out the associated decoding and patching
  logic from rules, and remove Build-Depends on sharutils and quilt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
#
 
3
# grace font updater
 
4
#  Copyright 2010 Kenshi Muto <kmuto@debian.org>
 
5
# License: GNU General Public License Version 2
 
6
#
 
7
my $orgt1dir = "/usr/share/fonts/type1";
 
8
my $gt1dir = "/usr/share/grace/fonts/type1";
 
9
my $fontbase = "/usr/share/grace/fonts/FontDataBase";
 
10
 
 
11
sub recursiveLink {
 
12
    my($odir, $cdir) = @_;
 
13
    opendir(my $dh, $odir);
 
14
    my @files = readdir($dh);
 
15
    foreach (@files) {
 
16
        next if (/^\./);
 
17
        recursiveLink("$odir/$_", $cdir) if -d "$odir/$_";
 
18
        symlink("$odir/$_", "$cdir/$_") if -f "$odir/$_";
 
19
    }
 
20
    closedir($dh);
 
21
}
 
22
 
 
23
# cleanup (remove symlink only)
 
24
opendir(my $dh, $gt1dir) || die "Can't open $gt1dir: $!\n";
 
25
my @files = readdir($dh);
 
26
foreach (@files) {
 
27
    next if (/^\./);
 
28
    unlink "$gt1dir/$_" if -l "$gt1dir/$_";
 
29
}
 
30
closedir($dh);
 
31
 
 
32
# symlink from original font directory
 
33
recursiveLink($orgt1dir, $gt1dir);
 
34
 
 
35
# define essential Postscript font map
 
36
my(%map) = (
 
37
    "Times-Roman" => "n021003l.pfb",
 
38
    "Times-Italic" => "n021023l.pfb",
 
39
    "Times-Bold" => "n021004l.pfb",
 
40
    "Times-BoldItalic" => "n021024l.pfb",
 
41
    "Helvetica" => "n019003l.pfb",
 
42
    "Helvetica-Oblique" => "n019023l.pfb",
 
43
    "Helvetica-Bold" => "n019004l.pfb",
 
44
    "Helvetica-BoldOblique" => "n019024l.pfb",
 
45
    "Courier" => "n022003l.pfb",
 
46
    "Courier-Oblique" => "n022023l.pfb",
 
47
    "Courier-Bold" => "n022004l.pfb",
 
48
    "Courier-BoldOblique" => "n022024l.pfb",
 
49
    "Symbol" => "s050000l.pfb",
 
50
    "ZapfDingbats" => "d050000l.pfb",
 
51
);
 
52
 
 
53
# scan font files
 
54
chdir("$gt1dir");
 
55
open(my $ph, "fc-scan -f '%{fontformat}\t%{family}-%{style}\t%{file}\n' . |") || die "Can't execute fc-scan: $!\n";
 
56
while (<$ph>) {
 
57
    chomp;
 
58
    my($fontformat, $familystyle, $file) = split(/\t/);
 
59
    next if $fontformat ne "Type 1";
 
60
    $familystyle =~ s/ //g;
 
61
    $file =~ s/^\.\///;
 
62
    $map{$familystyle} = $file;
 
63
}
 
64
close($ph);
 
65
 
 
66
# dump FontDatabase
 
67
open(my $fh, ">$fontbase") || die "Can't create $fontbase: $!\n";
 
68
print $fh (scalar(keys %map));
 
69
print $fh "\n";
 
70
foreach (sort keys %map) {
 
71
    print $fh "$_ $_ " . $map{$_} . "\n";
 
72
}
 
73
close($fontbase);