~ubuntu-branches/ubuntu/precise/graphviz/precise-security

« back to all changes in this revision

Viewing changes to debian/mksvgfonts.pl

  • Committer: Bazaar Package Importer
  • Author(s): David Claughton
  • Date: 2010-03-24 22:45:18 UTC
  • mfrom: (1.2.7 upstream) (6.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100324224518-do441tthbqjaqjzd
Tags: 2.26.3-4
Add patch to fix segfault in circo. Backported from upstream snapshot
release.  Thanks to Francis Russell for his work on this.
(Closes: #575255)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
# translate a ghostscript config to a graphviz ps_font_equiv.h table
 
4
use English;
 
5
my %features = ();
 
6
 
 
7
my %map = (
 
8
"roman" => "serif",
 
9
"sans-serif" => "sans-Serif",
 
10
"typewriter" => "monospace"
 
11
);
 
12
 
 
13
# weight normal or bold
 
14
# style normal or italic
 
15
 
 
16
if ($#ARGV + 1 != 2) { die "usage: cf2psfe.pl fontmap.cfg ps_font_equiv.txt";}
 
17
 
 
18
open(CONFIG,"< $ARGV[0]");
 
19
while (<CONFIG>) {
 
20
        next if /^#/;
 
21
        if (/\[(.+)\]/) { $fontname = $1;}
 
22
        if (/features\s*=\s*(.+)/) { $features{$fontname} = $1;}
 
23
}
 
24
 
 
25
open(SOURCE,"< $ARGV[1]");
 
26
while (<SOURCE>) {
 
27
        my ($fontfam, $weight, $style);
 
28
        m/"([^"]+)"/;
 
29
        $f = $features{$1};
 
30
        while (($key,$value) = each(%map)) {
 
31
                $fontfam = $value if ($f =~ /$key/);
 
32
        }
 
33
        $style = ($f =~ /italic/? q("italic") : 0);
 
34
        $weight= ($f =~ /bold/? q("bold") : 0);
 
35
        if ($fontfam eq "") {warn "don't know about $1\n"; $fontfam = "fantasy";}
 
36
        $_ =~ s/},$/,\t\"$fontfam\",\t$weight,\t$style},/;
 
37
        print $_;
 
38
}