author | Alan Coopersmith <Alan.Coopersmith@Sun.COM> |
Mon, 23 Nov 2009 11:58:12 -0800 | |
changeset 837 | ee480af8e87c |
parent 222 | 73975f82276f |
child 907 | 3c35d611cdaa |
permissions | -rwxr-xr-x |
222
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
1 |
#! /usr/perl5/bin/perl |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
2 |
# |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
3 |
# Copyright 2007 Sun Microsystems, Inc. All rights reserved. |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
4 |
# Use is subject to license terms. |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
5 |
# |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
6 |
# Permission is hereby granted, free of charge, to any person obtaining a |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
7 |
# copy of this software and associated documentation files (the |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
8 |
# "Software"), to deal in the Software without restriction, including |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
9 |
# without limitation the rights to use, copy, modify, merge, publish, |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
10 |
# distribute, and/or sell copies of the Software, and to permit persons |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
11 |
# to whom the Software is furnished to do so, provided that the above |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
12 |
# copyright notice(s) and this permission notice appear in all copies of |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
13 |
# the Software and that both the above copyright notice(s) and this |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
14 |
# permission notice appear in supporting documentation. |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
15 |
# |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
16 |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
17 |
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
18 |
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
19 |
# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
20 |
# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
21 |
# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
22 |
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
23 |
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
24 |
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
25 |
# |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
26 |
# Except as contained in this notice, the name of a copyright holder |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
27 |
# shall not be used in advertising or otherwise to promote the sale, use |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
28 |
# or other dealings in this Software without prior written authorization |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
29 |
# of the copyright holder. |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
30 |
# |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
31 |
# ident "@(#)merge-fonts.scale.pl 1.1 07/09/14 SMI" |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
32 |
# |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
33 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
34 |
# Merge fonts.scale files |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
35 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
36 |
use strict; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
37 |
use warnings; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
38 |
use integer; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
39 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
40 |
use Getopt::Long; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
41 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
42 |
my @infiles; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
43 |
my $outfile; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
44 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
45 |
my $options_ok = GetOptions( |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
46 |
"in=s" => \@infiles, # --in=<filename>, may be repeated |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
47 |
"out=s" => \$outfile); # --out=<filename>, only once |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
48 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
49 |
die "Invalid options" if !$options_ok; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
50 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
51 |
die "No input specified" if (scalar(@infiles) < 1); |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
52 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
53 |
die "No output specified" if !defined($outfile); |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
54 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
55 |
my %fonts = (); |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
56 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
57 |
for my $f (@infiles) { |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
58 |
open my $IN, '<', $f or die "Couldn't open $f for reading: $!\n"; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
59 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
60 |
my $firstline = <$IN>; # count of lines, ignore |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
61 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
62 |
while (my $l = <$IN>) { |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
63 |
chomp $l; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
64 |
$l =~ m/(\S*)\s+(.*)/; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
65 |
$fonts{$2} = $1; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
66 |
} |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
67 |
close $IN; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
68 |
} |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
69 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
70 |
open my $OUT, '>', $outfile or die "Couldn't open $outfile for writing: $!\n"; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
71 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
72 |
print $OUT scalar(keys %fonts), "\n"; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
73 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
74 |
for my $ft (sort {$fonts{$a} cmp $fonts{$b}} keys %fonts) { |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
75 |
print $OUT $fonts{$ft}, ' ', $ft, "\n"; |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
76 |
} |
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
77 |
|
73975f82276f
6470670 Include DejaVu fonts in Solaris
Alan Coopersmith <Alan.Coopersmith@Sun.COM>
parents:
diff
changeset
|
78 |
close $OUT or die "Couldn't finish writing $outfile: $!\n"; |