diff options
-rwxr-xr-x | tools/credits.pl | 81 |
1 files changed, 69 insertions, 12 deletions
diff --git a/tools/credits.pl b/tools/credits.pl index a9c43353b8..e6755abe80 100755 --- a/tools/credits.pl +++ b/tools/credits.pl @@ -27,16 +27,17 @@ my $indent; my $tab; if ($#ARGV >= 0) { - $mode = "TEXT" if ($ARGV[0] eq "--text"); # AUTHROS + $mode = "TEXT" if ($ARGV[0] eq "--text"); # AUTHORS file $mode = "HTML" if ($ARGV[0] eq "--html"); # credits.inc (for use on the website) $mode = "CPP" if ($ARGV[0] eq "--cpp"); # credits.h (for use by about.cpp) $mode = "XML" if ($ARGV[0] eq "--xml"); # credits.xml (DocBook) + $mode = "RTF" if ($ARGV[0] eq "--rtf"); # Credits.rtf (Mac OS X About box) #$mode = "TEX" if ($ARGV[0] eq "--tex"); # 10.tex (LaTeX) } if ($mode eq "") { - print STDERR "Usage: credits.pl [--text | --html | --cpp | --xml]\n"; - print STDERR " Just pass --text / --html / --cpp / --xml as parameter, and credits.pl\n"; + print STDERR "Usage: credits.pl [--text | --html | --cpp | --xml | --rtf]\n"; + print STDERR " Just pass --text / --html / --cpp / --xml / --rtf as parameter, and credits.pl\n"; print STDERR " will print out the corresponding version of the credits to stdout.\n"; exit 1; } @@ -52,7 +53,7 @@ if ($mode eq "TEXT") { } # Convert HTML entities to ASCII for the plain text mode -sub convert_html_entities { +sub html_entities_to_ascii { my $text = shift; # For now we hardcode these mappings @@ -76,11 +77,32 @@ sub convert_html_entities { return $text; } +# Convert HTML entities to RTF codes +sub html_entities_to_rtf { + my $text = shift; + + $text =~ s/á/\\'87/g; + $text =~ s/é/\\'8e/g; + $text =~ s/ø/\\'bf/g; + $text =~ s/ł/\\uc0\\u322 /g; + $text =~ s/ö/\\'9a/g; + + $text =~ s/&/&/g; + + return $text; +} + sub begin_credits { my $title = shift; if ($mode eq "TEXT") { - #print convert_html_entities($title)."\n"; + #print html_entities_to_ascii($title)."\n"; + } elsif ($mode eq "RTF") { + print '{\rtf1\mac\ansicpg10000\cocoartf102' . "\n"; + print '{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;}' . "\n"; + print '{\colortbl;\red255\green255\blue255;\red0\green128\blue0;}' . "\n"; + print '\vieww6920\viewh15480\viewkind0' . "\n"; + print "\n"; } elsif ($mode eq "CPP") { print "// This file was generated by credits.pl. Do not edit by hand!\n"; print "static const char *credits[] = {\n"; @@ -103,6 +125,8 @@ sub begin_credits { sub end_credits { if ($mode eq "TEXT") { + } elsif ($mode eq "RTF") { + print "}\n"; } elsif ($mode eq "CPP") { print "};\n"; } elsif ($mode eq "XML") { @@ -118,10 +142,20 @@ sub end_credits { sub begin_section { my $title = shift; if ($mode eq "TEXT") { - $title = convert_html_entities($title); + $title = html_entities_to_ascii($title); print $title.":\n"; + } elsif ($mode eq "RTF") { + $title = html_entities_to_rtf($title); + + # Center text + print '\pard\qc' . "\n"; + print '\f0\b\fs28 \cf2 ' . $title . "\n"; + print '\f1\b0\fs24 \cf0 \\' . "\n"; +# print '\pard\tx565\li574\fi-574\ql\qnatural' . "\n"; + # Switch back to base font + print '\cf0' . "\n"; } elsif ($mode eq "CPP") { - $title = convert_html_entities($title); + $title = html_entities_to_ascii($title); print '"\\\\C\\\\c1""'.$title.':",' . "\n"; } elsif ($mode eq "XML") { print " <row><entry namest='start' nameend='job'>"; @@ -135,6 +169,8 @@ sub begin_section { sub end_section { if ($mode eq "TEXT") { print "\n"; + } elsif ($mode eq "RTF") { + print "\\\n"; } elsif ($mode eq "CPP") { print '"\\\\L\\\\c0""",' . "\n"; } elsif ($mode eq "XML") { @@ -151,8 +187,8 @@ sub add_person { if ($mode eq "TEXT") { $name = $nick if $name eq ""; - $name = convert_html_entities($name); - $desc = convert_html_entities($desc); + $name = html_entities_to_ascii($name); + $desc = html_entities_to_ascii($desc); printf $tab."%-".$max_name_width.".".$max_name_width."s - ", $name; @@ -160,10 +196,26 @@ sub add_person { my $inner_indent = $indent + $max_name_width + 3; my $multitab = " " x $inner_indent; print substr(wrap($multitab, $multitab, $desc), $inner_indent)."\n" + } elsif ($mode eq "RTF") { + $name = $nick if $name eq ""; + $name = html_entities_to_rtf($name); + $desc = html_entities_to_rtf($desc); + + # Left align name + print '\pard\ql\qnatural' . "\n"; + print $name . "\\\n"; + + # Left align description, with a left indention + print '\pard\li560\ql\qnatural' . "\n"; + # Italics + print "\\i " . $desc . "\\i0\\\n"; +# print $name . "\\\n"; +# print "\\i\t" . $desc . "\\i0\\\n"; +## print "\t" . $name . "\t- " . $desc . "\\\n"; } elsif ($mode eq "CPP") { $name = $nick if $name eq ""; - $name = convert_html_entities($name); - $desc = convert_html_entities($desc); + $name = html_entities_to_ascii($name); + $desc = html_entities_to_ascii($desc); print '"\\\\L\\\\c0"" '.$name.'",' . "\n"; @@ -195,8 +247,13 @@ sub add_paragraph { my $text = shift; if ($mode eq "TEXT") { - print wrap($tab, $tab, convert_html_entities($text))."\n"; + print wrap($tab, $tab, html_entities_to_ascii($text))."\n"; print "\n"; + } elsif ($mode eq "RTF") { + # Left align text + print '\pard\ql\qnatural' . "\n"; + print $text . "\\\n"; + print "\\\n"; } elsif ($mode eq "CPP") { my $line_start = '"\\\\L\\\\c0""'; my $line_end = '",'; |