[3019] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
| 3 | # Copyright (c) 1998-2000 |
---|
| 4 | # Sergey A. Babkin. All rights reserved. |
---|
| 5 | # |
---|
| 6 | # Redistribution and use in source and binary forms, with or without |
---|
| 7 | # modification, are permitted provided that the following conditions |
---|
| 8 | # are met: |
---|
| 9 | # 1. Redistributions of source code must retain the above copyright |
---|
| 10 | # notice, this list of conditions and the following disclaimer. |
---|
| 11 | # 2. Redistributions in binary form must reproduce the above copyright |
---|
| 12 | # notice, this list of conditions and the following disclaimer in the |
---|
| 13 | # documentation and/or other materials provided with the distribution. |
---|
| 14 | # |
---|
| 15 | # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
---|
| 16 | # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
---|
| 17 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
| 18 | # |
---|
| 19 | # Sergey A. Babkin (sab123@hotmail.com, babkin@bellatlantic.net) |
---|
| 20 | # |
---|
| 21 | |
---|
| 22 | # Use : x2gs [cfgfile] |
---|
| 23 | |
---|
| 24 | # path to the configuration file |
---|
| 25 | |
---|
| 26 | if [ $# -eq 1 ] |
---|
| 27 | then |
---|
| 28 | CFGFILE=$1 |
---|
| 29 | else |
---|
| 30 | CFGFILE=`pwd`/convert.cfg |
---|
| 31 | fi |
---|
| 32 | |
---|
| 33 | MYSELF=x2gs |
---|
| 34 | |
---|
| 35 | # include the configuration |
---|
| 36 | |
---|
| 37 | if [ -r $CFGFILE ] |
---|
| 38 | then { |
---|
| 39 | . $CFGFILE |
---|
| 40 | } else { |
---|
| 41 | echo " |
---|
| 42 | Can't find the configuration file |
---|
| 43 | $CFGFILE |
---|
| 44 | Please look at the sample file convert.cfg.sample, |
---|
| 45 | copy it to convert.cfg and modify for |
---|
| 46 | you actual configuration." >&2 |
---|
| 47 | exit 1 |
---|
| 48 | } fi |
---|
| 49 | |
---|
| 50 | LOG=$DSTDIR/convert.log |
---|
| 51 | |
---|
| 52 | [ -n "$GSDIR" ] || { |
---|
| 53 | echo "$MYSELF: The Ghostscript base directory is not specified." >&2 |
---|
| 54 | echo "$MYSELF: Installation of the Ghostscript fonts is deferred." >&2 |
---|
| 55 | exit 0 |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | [ -n "$GSCONFDIR" -a -d "$GSCONFDIR" ] || { |
---|
| 59 | echo "$MYSELF: The Ghostscript configuration directory does not exist." >&2 |
---|
| 60 | echo "$MYSELF: Installation of the Ghostscript fonts is aborted." >&2 |
---|
| 61 | exit 1 |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | [ -r "$GSCONFDIR/Fontmap" ] || { |
---|
| 65 | echo "$MYSELF: Can't find Fontmap in the GS configuration directory." >&2 |
---|
| 66 | echo "$MYSELF: Installation of the Ghostscript fonts is aborted." >&2 |
---|
| 67 | exit 1 |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | [ -n "$GSFONTDIR" -a -d "$GSFONTDIR" ] || { |
---|
| 71 | echo "$MYSELF: The Ghostscript font directory does not exist." >&2 |
---|
| 72 | echo "$MYSELF: Installation of the Ghostscript fonts is aborted." >&2 |
---|
| 73 | exit 1 |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | # link the fonts to $GSFONTDIR |
---|
| 77 | |
---|
| 78 | rm -f $GSCONFDIR/Fontmap.ttf |
---|
| 79 | |
---|
| 80 | # historically x2gs supported multiple X11 directories |
---|
| 81 | for d in $DSTDIR |
---|
| 82 | do { |
---|
| 83 | for i in $d/*.pfa $d/*.afm |
---|
| 84 | do { |
---|
| 85 | [ -f $i ] || break; |
---|
| 86 | |
---|
| 87 | n=`basename $i` |
---|
| 88 | |
---|
| 89 | rm -f $GSFONTDIR/$n |
---|
| 90 | |
---|
| 91 | ln -s $i $GSFONTDIR/$n || { |
---|
| 92 | echo "$MYSELF: Unable to link $n to GS font directory">&2 |
---|
| 93 | } |
---|
| 94 | } done |
---|
| 95 | |
---|
| 96 | cat $d/Fontmap.ttf >>$GSCONFDIR/Fontmap.ttf |
---|
| 97 | } done |
---|
| 98 | |
---|
| 99 | if [ YES = "$INSTALLFONTMAP" ] |
---|
| 100 | then { |
---|
| 101 | mv $GSCONFDIR/Fontmap $GSCONFDIR/Fontmap.old || { |
---|
| 102 | echo "$MYSELF: can't save Fontmap.old" >&2 |
---|
| 103 | exit 1 |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | sed "\\|^% begin fonts from $DSTDIR|,\\|^% end fonts from $DSTDIR|d" \ |
---|
| 107 | <$GSCONFDIR/Fontmap.old >$GSCONFDIR/Fontmap || { |
---|
| 108 | echo "$MYSELF: Can't create the new Fontmap file" >&2 |
---|
| 109 | echo "$MYSELF: Trying to restore the old Fontmap file" >&2 |
---|
| 110 | cp $GSCONFDIR/Fontmap.old $GSCONFDIR/Fontmap |
---|
| 111 | exit 1 |
---|
| 112 | } |
---|
| 113 | echo "% begin fonts from $DSTDIR" >>$GSCONFDIR/Fontmap |
---|
| 114 | echo "" >>$GSCONFDIR/Fontmap |
---|
| 115 | cat $GSCONFDIR/Fontmap.ttf >>$GSCONFDIR/Fontmap |
---|
| 116 | echo "" >>$GSCONFDIR/Fontmap |
---|
| 117 | echo "% end fonts from $DSTDIR" >>$GSCONFDIR/Fontmap |
---|
| 118 | } fi |
---|