File: mksvgfonts.pl

package info (click to toggle)
graphviz 12.2.1-1
  • links: PTS
  • area: main
  • in suites: experimental
  • size: 78,996 kB
  • sloc: ansic: 141,865; cpp: 12,016; python: 6,862; makefile: 3,950; tcl: 3,092; yacc: 3,029; xml: 2,972; sh: 1,321; objc: 1,159; java: 560; lex: 427; perl: 243; awk: 156; pascal: 138; php: 58; ruby: 49; cs: 31; sed: 1
file content (38 lines) | stat: -rwxr-xr-x 922 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl

# translate a ghostscript config to a graphviz ps_font_equiv.h table
use English;
my %features = ();

my %map = (
"roman" => "serif",
"sans-serif" => "sans-Serif",
"typewriter" => "monospace"
);

# weight normal or bold
# style normal or italic

if ($#ARGV + 1 != 2) { die "usage: cf2psfe.pl fontmap.cfg ps_font_equiv.txt";}

open(CONFIG,"< $ARGV[0]");
while (<CONFIG>) {
	next if /^#/;
	if (/\[(.+)\]/) { $fontname = $1;}
	if (/features\s*=\s*(.+)/) { $features{$fontname} = $1;}
}

open(SOURCE,"< $ARGV[1]");
while (<SOURCE>) {
	my ($fontfam, $weight, $style);
	m/"([^"]+)"/;
	$f = $features{$1};
	while (($key,$value) = each(%map)) {
		$fontfam = $value if ($f =~ /$key/);
	}
	$style = ($f =~ /italic/? q("italic") : 0);
	$weight= ($f =~ /bold/? q("bold") : 0);
	if ($fontfam eq "") {warn "don't know about $1\n"; $fontfam = "fantasy";}
	$_ =~ s/},$/,\t\"$fontfam\",\t$weight,\t$style},/;
	print $_;
}