Root/scripts/normalizeschps

Source at commit b3f201486360ad2ffeb7d1ac24d14972d850f8ca created 10 years 24 days ago.
By Werner Almesberger, Split gitsch2ppm into its constituents.
1#!/bin/sh
2#
3# normalizeschps - Normalize eeschema Postscript
4#
5# Written 2010 by Werner Almesberger
6# Copyright 2010 Werner Almesberger
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13
14
15LINEWIDTH=120
16
17
18usage()
19{
20    cat <<EOF 1>&2
21usage: $0 [options] file ...
22
23  -w points Postscript line width (default: $LINEWIDTH)
24EOF
25    exit 1
26}
27
28
29while true; do
30    case "$1" in
31    -w) [ -z "$2" ] && usage
32    LINEWIDTH="$2"
33    shift 2;;
34    -*)
35    usage;;
36    *)
37    break;;
38    esac
39done
40
41for n in "$@"; do
42    sed -i '
43      1c%!PS-Adobe-3.0\
44      currentdict /DidNormalize known not { \
45          /setlinewidth { '$LINEWIDTH' 2 copy lt { exch } if pop \
46            setlinewidth } bind def \
47          /rectfill { rectstroke } bind def \
48      /DidNormalize true def \
49      } if \
50      gsave
51      /%%DocumentMedia: A4.*/a-20 -10 translate
52      /%%DocumentMedia: A3.*/{s/A3/A4/;a-20 -10 translate 0.70 dup scale
53      }
54      /%%DocumentMedia: A2.*/{s/A2/A4/;a-18 -12 translate 0.49 dup scale
55      }
56      $agrestore' "$n"
57done
58
59# /%%Orientation: Landscape/d' "$n"
60

Archive Download this file



interactive