[Indic-computing-cvs-logs] SF.net SVN: indic-computing: [307] doc/trunk/share/misc
Status: Alpha
Brought to you by:
jkoshy
From: <jk...@us...> - 2007-10-12 06:00:36
|
Revision: 307 http://indic-computing.svn.sourceforge.net/indic-computing/?rev=307&view=rev Author: jkoshy Date: 2007-10-11 23:00:38 -0700 (Thu, 11 Oct 2007) Log Message: ----------- Bring two scripts used during documentation builds under revision control: * "epsgeom" is used to retrieve the bounding box for EPS figures. [1] * "process-indic-extensions" is a post-processor for indic elements. Obtained from: The FreeBSD Documentation Project [1] Added Paths: ----------- doc/trunk/share/misc/epsgeom doc/trunk/share/misc/process-indic-extensions Added: doc/trunk/share/misc/epsgeom =================================================================== --- doc/trunk/share/misc/epsgeom (rev 0) +++ doc/trunk/share/misc/epsgeom 2007-10-12 06:00:38 UTC (rev 307) @@ -0,0 +1,102 @@ +#!/usr/bin/perl -w +# $FreeBSD: doc/share/misc/epsgeom,v 1.2 2004/07/23 18:58:55 hrs Exp $ +# +# epsgeom - extract geometry from a EPS file. +# +# Copyright (C) 2004 The FreeBSD Project. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +my $x; +my $y; +my $width; +my $height; + +my $gx; +my $gy; + +if (@ARGV != 4) { + die "Error: invalid arguments.\n"; +} + +my $mode = shift @ARGV; +my $hres = shift @ARGV; +my $vres = shift @ARGV; +my $file = shift @ARGV; + +my $realfile = `realpath ${file}`; +chomp $realfile; + +open IN, "<$realfile" or die "Error: cannot open $realfile.\n"; +while(<IN>) { + last if (($x,$y,$width,$height) = + /^%%BoundingBox:\s+([-\d]+)\s+([-\d]+)\s+([-\d]+)\s+([-\d]+)/); + #print STDERR "DEBUG: $_"; +} +close IN; + +if (not defined($x)) { + die "Error: no BoundingBox found.\n"; +} + +$width -= $x; +$height -= $y; + +# (int)(((double)hres * (double)width / 72.0) + 0.5), +$gx = $hres * $width / 72.0 + 0.5; +# (int)(((double)vres * (double)height / 72.0) + 0.5), +$gy = $vres * $height / 72.0 + 0.5; + +my %replace = ( + '@X@' => int $x, + '@Y@' => int $y, + '@MX@' => int -$x, + '@MY@' => int -$y, + '@WIDTH@' => int $width, + '@MWIDTH@' => int -$width, + '@HEIGHT@' => int $height, + '@MHEIGHT@' => int -$height, + '@ANGLE@' => int 0, + '@INPUT@' => $realfile, + ); + +if ($mode eq "-replace") { + foreach my $i (keys %replace) { + printf "-e s,%s,%s,g ", $i, $replace{$i}; + } +} elsif ($mode eq "-offset") { + #print STDERR "DEBUG: (int -$x), $y\n"; + printf "<< /PageOffset [%d %d] >> setpagedevice\n", (int -$x), $y; + open IN, "<$realfile" or die "Error: cannot open $realfile.\n"; + print while(<IN>); + close IN; + print "\n"; + print "showpage\n"; +} elsif ($mode eq "-geom") { + #print STDERR "DEBUG: $x,$y,$width,$height\n"; + printf "%dx%d", $gx, $gy; +} else { + die "Error: invalid mode specified.\n"; +} + +__END__ Property changes on: doc/trunk/share/misc/epsgeom ___________________________________________________________________ Name: svn:executable + * Added: doc/trunk/share/misc/process-indic-extensions =================================================================== --- doc/trunk/share/misc/process-indic-extensions (rev 0) +++ doc/trunk/share/misc/process-indic-extensions 2007-10-12 06:00:38 UTC (rev 307) @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# +# The Indic-Computing Project +# +# Convert a textual specification of graphemes and text to be drawn, +# convert these to the appropriate representation for HTML and TeX +# input. +# +# $Id$ +# + +import os, getopt, sys, tempfile + +options = "HTcl" +longoptions = [ "config", "html", "list", "tex" ] + +usagemessage = "usage: " + sys.argv[0] + """[options] specification-file +Valid options include: + -H, --html create HTML compatible images + -T, --text create TeX sequences (unimplemented) + -c, --config read config [default: .pieconfig] + -l, --list list generated files without creating them +""" + +def error(message, usage=None): + "Display an error message, an optional usage message and exit." + print sys.argv[0] + ": ERROR:", message + if usage: print usage + sys.exit(1) + +## +# +# Variables +# +## + +output_mode = None + +# parse options +try: + opts, remainder = getopt.getopt(sys.argv[1:], options, longoptions) +except getopt.GetoptError, err: + error(err, usagemessage) + +for f,v in opts: + if f in ["-H", "--html"]: + output_mode = 'html' + elif f in ["-T", "--tex"]: + output_mode = 'tex' + + +# +# Local Variables: +# mode: python +# End: Property changes on: doc/trunk/share/misc/process-indic-extensions ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |