From: north Date: Tue, 6 Feb 2007 20:04:06 +0000 (+0000) Subject: Some improvements on translation of fontnames for the native svg codegen. X-Git-Tag: LAST_LIBGRAPH~32^2~5681 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e17f8ceae102aeb10aa7ccd62712c833cf15d729;p=graphviz Some improvements on translation of fontnames for the native svg codegen. --- diff --git a/lib/common/mksvgfonts.pl b/lib/common/mksvgfonts.pl new file mode 100755 index 000000000..1802eec17 --- /dev/null +++ b/lib/common/mksvgfonts.pl @@ -0,0 +1,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 () { + next if /^#/; + if (/\[(.+)\]/) { $fontname = $1;} + if (/features\s*=\s*(.+)/) { $features{$fontname} = $1;} +} + +open(SOURCE,"< $ARGV[1]"); +while () { + 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 $_; +}