[comp.sources.x] v12i004: bdftools -- tools for working with BDF fonts, Part01/02

mleisher@NMSU.Edu (03/02/91)

Submitted-by: mleisher@NMSU.Edu
Posting-number: Volume 12, Issue 4
Archive-name: bdftools/part01

---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is bdftools/part, a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 02/25/1991 05:04 UTC by mleisher@nmsu.edu
# Source directory /tmp_mnt/home/nikita1/X11R4/contrib/fonts
#
# existing files will NOT be overwritten unless -c is specified
#
# This is part 1 of a multipart archive                                    
# do not concatenate these parts, unpack them in order with /bin/sh        
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#    513 -rw-rw-r-- bdftools/README
#   6165 -rw-rw-r-- bdftools/bdftops-1.1/bdftops.c
#   2082 -rw-rw-r-- bdftools/bdftops-1.1/bdftops.man
#   1586 -rw-rw-r-- bdftools/bdftops-1.1/README
#     22 -rw-rw-r-- bdftools/bdftops-1.1/patchlevel.h
#    337 -rw-rw-r-- bdftools/bdftops-1.1/Imakefile
#   9117 -rw-rw-r-- bdftools/bdftops-1.1/Makefile
#    217 -rw-rw-r-- bdftools/bintobdf-1.0/Imakefile
#  11688 -rw-rw-r-- bdftools/bintobdf-1.0/bintobdf.c
#    680 -rw-rw-r-- bdftools/bintobdf-1.0/bintobdf.h
#   3475 -rw-rw-r-- bdftools/bintobdf-1.0/bintobdf.man
#     21 -rw-rw-r-- bdftools/bintobdf-1.0/patchlevel.h
#   1685 -rw-rw-r-- bdftools/bintobdf-1.0/README
#    441 -rw-rw-r-- bdftools/snftobdf-1.4/Imakefile
#    178 -rw-rw-r-- bdftools/snftobdf-1.4/MANIFEST
#   9230 -rw-rw-r-- bdftools/snftobdf-1.4/Makefile
#   2716 -rw-rw-r-- bdftools/snftobdf-1.4/README
#   3915 -rw-rw-r-- bdftools/snftobdf-1.4/input.c
#   5991 -rw-rw-r-- bdftools/snftobdf-1.4/output.c
#   2543 -rw-rw-r-- bdftools/snftobdf-1.4/snftobdf.c
#     21 -rw-rw-r-- bdftools/snftobdf-1.4/patchlevel.h
#   1083 -rw-rw-r-- bdftools/snftobdf-1.4/snftobdf.h
#   1074 -rw-rw-r-- bdftools/snftobdf-1.4/snftobdf.man
#
if test -r _shar_seq_.tmp; then
	echo 'Must unpack archives in sequence!'
	echo Please unpack part `cat _shar_seq_.tmp` next
	exit 1
fi
# ============= bdftools/README ==============
if test ! -d 'bdftools'; then
    echo 'x - creating directory bdftools'
    mkdir 'bdftools'
fi
if test -f 'bdftools/README' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/README (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/README' &&
Here are three utilities for working with BDF format fonts:
1. bdftops 1.1 - converts a BDF font into a bitmapped Postscript font
X
2. bintobdf 1.0 - converts a raw bitmap font into a BDF font
X                  (designed primarily for working with Oriental fonts)
X
3. snftobdf 1.4 - converts an SNF format font into a BDF format font
X
Please send fixes, additions, etc. to:
X
Internet: mleisher@nmsu.edu
Bitnet  : mleisher@nmsu.bitnet
X
Mark Leisher
Computing Research Lab
New Mexico State University
Las Cruces, NM
SHAR_EOF
chmod 0664 bdftools/README ||
echo 'restore of bdftools/README failed'
Wc_c="`wc -c < 'bdftools/README'`"
test 513 -eq "$Wc_c" ||
	echo 'bdftools/README: original size 513, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bdftops-1.1/bdftops.c ==============
if test ! -d 'bdftools/bdftops-1.1'; then
    echo 'x - creating directory bdftools/bdftops-1.1'
    mkdir 'bdftools/bdftops-1.1'
fi
if test -f 'bdftools/bdftops-1.1/bdftops.c' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bdftops-1.1/bdftops.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bdftops-1.1/bdftops.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bdftops-1.1/bdftops.c' &&
#include <stdio.h>
X
char *program, *fontname;
char buff[128];
int fontno = 1;
X
int w, h, psize, resX, resY;
double unit_width, unit_height;
double width_scale;
double bbx_llx, bbx_lly, bbx_urx, bbx_ury;
X
char *
get_fontname(str)
char *str;
{
X    int len;
X    char *ptr, *ptr1, *tmp_name;
X
X    if (str == NULL) {
X        tmp_name = (char *)malloc(20 * sizeof(char));
X        sprintf(tmp_name, "BDF FONT %d", fontno++);
X        return(tmp_name);
X    }
X    len = strlen(str);
X    ptr = str + (len - 1);
X    while(ptr > str && *ptr != '.')
X      ptr--;
X    if (ptr == str)
X      return(str);
X    ptr1 = ptr;
X    while(ptr1 > str && *ptr1 != '/')
X      ptr1--;
X    if (*ptr1 == '/')
X      ptr1++;
X
X    tmp_name = (char *)malloc(((ptr - ptr1) + 1) * sizeof(char));
X    strncpy(tmp_name, ptr1, (ptr - ptr1));
X    tmp_name[(ptr - ptr1)] = '\0';
X    return(tmp_name);
}
X
void
header(in)
FILE *in;
{
X    int dx, dy;
X    int i, count, ndx, ndy;
X
X    printf("%%!PS-Adobe-2.0\n");
X    printf("10 dict dup begin\n");
X    printf("/FontType 3 def\n");
X    printf("/FontMatrix [1 0 0 1 0 0] def\n");
X
X    fscanf(in, "%[^\n]\n", buff);
X    while(!feof(in) && strncmp(buff, "SIZE", 4))
X      fscanf(in, "%[^\n]\n", buff);
X    if (strncmp(buff, "SIZE", 4)) {
X        fprintf(stderr, "%s: missing SIZE\n");
X        exit(1);
X    }
X    sscanf(buff, "SIZE %d %d %d", &psize, &resX, &resY);
X
X    width_scale = (((double)psize)/1000.0) * (((double)resX)/72.27);
X
X    while(!feof(in) && strncmp(buff, "FONTBOUNDINGBOX", 15))
X      fscanf(in, "%[^\n]\n", buff);
X    if (strncmp(buff, "FONTBOUNDINGBOX", 15)) {
X        fprintf(stderr, "%s: missing FONTBOUNDINGBOX\n");
X        exit(1);
X    }
X    sscanf(buff, "FONTBOUNDINGBOX %d %d %d %d", &w, &h, &dx, &dy);
X
X    ndx = (dx < 0) ? -(dx) : dx;
X    ndy = (dy < 0) ? -(dy) : dy;
X
X    unit_width = (double)(w + dx);
X    unit_height = (double)(h + dy);
X
X    bbx_llx = ((double)(w + ndx)) / unit_width;
X    bbx_urx = ((double) dx) / unit_width;
X
X    bbx_lly = ((double)(h + ndy)) / unit_height;
X    bbx_ury = ((double) dy) / unit_height;
X
X    printf("/FontBBox [%g %g %g %g] def\n", bbx_llx, bbx_lly, bbx_urx, bbx_ury);
X    printf("/Encoding 256 array def\n");
X    printf("0 1 255 {Encoding exch /.notdef put} for\n");
X    printf("Encoding\n");
X    count = 0;
X    for (i = 0; i < 255; i++) {
X        printf("dup %d /char%d put\t", i, i);
X        count++;
X        if (count % 3 == 0) {
X            count = 0;
X            printf("\n");
X        }
X    }
X    printf("255 /char255 put\n");
X    printf("/BuildChar\n{0 begin\n/char exch def\n/fontdict exch def\n");
X    printf("/charname fontdict /Encoding get char get def\n");
X    printf("/charinfo fontdict /CharData get charname get def\n");
X    printf("/wx charinfo 0 get def\n");
X    printf("/charbbox charinfo 1 4 getinterval def\n");
X    printf("wx 0 charbbox aload pop setcachedevice\n");
X    printf("charinfo 5 get charinfo 6 get true\n");
X    printf("fontdict /imagemaskmatrix get\n");
X    printf("dup 4 charinfo 7 get put\n");
X    printf("dup 5 charinfo 8 get put\n");
X    printf("charinfo 9 1 getinterval cvx imagemask\n");
X    printf("end } def\n");
X    printf("/BuildChar load 0 6 dict put\n");
X    printf("/imagemaskmatrix [%d 0 0 -%d 0 0] def\n", w, h);
X    printf("/CharData 256 dict def\nCharData begin\n");
}
X
void
gen_chars(in)
FILE *in;
{
X    int cw, ch, dx, dy, udx, udy, encoding, i;
X    int sw, dummy, count = 0;
X    double wx, llx, lly, urx, ury, ndx, ndy, tdx;
X
X    fscanf(in, "%[^\n]\n", buff);
X    while(!feof(in)) {
X        while(!feof(in) && strncmp(buff, "ENCODING", 8))
X          fscanf(in, "%[^\n]\n", buff);
X        if (feof(in))
X          break;
X        sscanf(buff, "ENCODING %d", &encoding);
X
X        if (encoding < 0 || encoding > 255) {
X            fscanf(in, "%[^\n]\n", buff);
X            continue;
X        }
X
X        while(!feof(in) && strncmp(buff, "SWIDTH", 6))
X          fscanf(in, "%[^\n]\n", buff);
X        if (feof(in))
X          break;
X        sscanf(buff, "SWIDTH %d %d", &sw, &dummy);
X
X        sw = (int)(((double)sw) * width_scale);
X        sw++;
X
X        if (!feof(in)) {
X            while(!feof(in) && strncmp(buff, "BBX", 3))
X              fscanf(in, "%[^\n]\n", buff);
X            if (feof(in))
X              break;
X            sscanf(buff, "BBX %d %d %d %d", &cw, &ch, &dx, &dy);
X
X            udx = (dx < 0) ? -(dx) : dx;
X            udy = (dy < 0) ? -(dy) : dy;
X
X            wx = ((double)sw) / unit_width;
X            if (wx == 0)
X              wx = ((double)w) * 0.01;
X
X            llx = ((double) dx) / unit_width;
X            urx = ((double)(sw + dx)) / unit_width;
X            llx = ((wx - (llx+urx)) < 0.0) ? -(llx) : llx;
X
X            lly = ((double) dy) / unit_height;
X            ury = ((double)(ch + udy)) / unit_height;
X
X            ury += bbx_lly - ury;
X
X            ndx = ((double)dx) + 0.5;
X            ndy = ((double)(ch + dy)) + 0.5;
X            printf("/char%d [%g %g %g %g %g %d %d %g %g\n<", encoding, wx, llx,
X                   lly, urx, ury, cw, ch, ndx, ndy);
X
X            fscanf(in, "%[^\n]\n", buff);
X            while(!feof(in) && strncmp(buff, "BITMAP", 6))
X              fscanf(in, "%[^\n]\n", buff);
X            if (feof(in))
X              break;
X            for (i = 0; i < ch; i++) {
X                fscanf(in, "%[^\n]", buff);
X                printf("%s", buff);
X                getc(in);  /* kill the EOL */
X            }
X            printf(">] def\n");
X        } else
X          fscanf(in, "%[^\n]\n", buff);
X        count++;
X    }
X    if (count < 256)
X      printf("/.notdef [%g 0 0 0 0 1 0 0 <>] def\n", ((double) w) * .01);
X    printf("end\nend\n/%s exch definefont pop\n", fontname);
}
X
X
main(argc, argv)
int argc;
char **argv;
{
X    FILE *in = stdin;
X
X    program = argv[0];
X
X    argc--;
X    *argv++;
X    while(argc) {
X        if (!(in = fopen(argv[0], "r")))
X          fprintf(stderr, "%s: problem with %s\n", program, argv[0]);
X        else {
X            fontname = get_fontname(argv[0]);
X            header(in);
X            gen_chars(in);
X            fclose(in);
X            in = NULL;
X        }
X        argc--;
X        *argv++;
X    }
X    if (in != NULL) {
X        header(in);
X        gen_chars(in);
X    }
}
SHAR_EOF
chmod 0664 bdftools/bdftops-1.1/bdftops.c ||
echo 'restore of bdftools/bdftops-1.1/bdftops.c failed'
Wc_c="`wc -c < 'bdftools/bdftops-1.1/bdftops.c'`"
test 6165 -eq "$Wc_c" ||
	echo 'bdftools/bdftops-1.1/bdftops.c: original size 6165, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bdftops-1.1/bdftops.man ==============
if test -f 'bdftools/bdftops-1.1/bdftops.man' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bdftops-1.1/bdftops.man (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bdftops-1.1/bdftops.man (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bdftops-1.1/bdftops.man' &&
.TH BDFTOPS 1 "Release 4" "X Version 11"
.SH NAME
bdftops - BDF font to Postscript font generator
.SH SYNOPSIS
.B "bdftops"
[bdf-file(s)]
.SH DESCRIPTION
.PP
.B bdftops
reads a Bitmap Distribution Format (BDF) file (or from standard input
if no file is specified on the command line) and produces a
Postscript font on standard output.
.sp
.B bdftops
will use the font filename minus the \fI.bdf\fP extension as
the name of the font, the full font filename if the \fI.bdf\fP extension is
not there, or a font name of "\fBBDF-FONT-\fIn\fP", where \fIn\fP is a
number, when a font file is read from standard input.
.SH "TUNING FONTS"
.B bdftops
depends on the SWIDTH (scalable width) x value heavily.  If this value
is not correct, then the horizontal offsets will be a little too
small, especially with variable width fonts.  Details of the SWIDTH
entry are described in the "Bitmap Distribution Format 2.1" document.
.sp
Variable width fonts will probably need a small amount of hand tuning
to get correct kerning.
.sp
An example of a Postscript character definition from the Adobe
Times-Roman 24(timR24.bdf) font:
.nf
\f(CW/char116 [0.230769 0 0 1 1 7 15 -0.5 14.5
<103070FE303030303030303030321C>] def\fP
.fi
.sp
The first number is the horziontal offset of the character that
follows this one, the next four numbers are the character's bounding
box for the font cacheing mechanism, the next two numbers are the
bitmap's width and height, and the last two numbers are horizontal and
vertical translations of the bitmap with .5 subtracted to handle
Postscript rounding errors.
.sp
This example in particular is a lower case ``t''.  The horizontal
offset of the next character is not quite right.  So the 0.230769
needs to be increased a little so that the character following the
``t'' is kerned correctly.
.SH "SEE ALSO"
XX(1), Xserver(1), bdftosnf(1)
.br
"Bitmap Distribution Format 2.1"
.SH AUTHOR
Internet: mleisher@nmsu.edu     Bitnet: mleisher@nmsu.bitnet
.br
Mark Leisher
.br
Computing Research Lab
.br
New Mexico State University
.br
Las Cruces, NM 88003
.br
(505) 646-5711
X
SHAR_EOF
chmod 0664 bdftools/bdftops-1.1/bdftops.man ||
echo 'restore of bdftools/bdftops-1.1/bdftops.man failed'
Wc_c="`wc -c < 'bdftools/bdftops-1.1/bdftops.man'`"
test 2082 -eq "$Wc_c" ||
	echo 'bdftools/bdftops-1.1/bdftops.man: original size 2082, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bdftops-1.1/README ==============
if test -f 'bdftools/bdftops-1.1/README' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bdftops-1.1/README (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bdftops-1.1/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bdftops-1.1/README' &&
--------------------------------------------------------------------
Copyright (C) 1990 Mark Leisher.
X
Author: Mark Leisher (mleisher@nmsu.edu)
X
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
X
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
X
A copy of the GNU General Public License can be obtained from this
program's author (send electronic mail to mleisher@nmsu.edu) or from
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
02139, USA.
--------------------------------------------------------------------
X
This program makes a Postscript font out from a BDF font.  It will not
work with large, two byte BDF fonts such as Chinese or Japanese BDF
fonts.  It also ignores any entries that have an ENCODING value less
than zero.
X
You might want to tune some of the Postscript parameters by hand to
get the output closer to what you want.  There is a short description
of this in the man page.
X
This program depends heavily on the SWIDTH entry for each character.
Please see the "Bitmap Distribution Format 2.1" document for details
on SWIDTH.  You can also send me email for a copy of this document.
X
Please send bug reports, enhancements, etc. to:
Internet: mleisher@nmsu.edu
Bitnet  : mleisher@nmsu.bitnet
SHAR_EOF
chmod 0664 bdftools/bdftops-1.1/README ||
echo 'restore of bdftools/bdftops-1.1/README failed'
Wc_c="`wc -c < 'bdftools/bdftops-1.1/README'`"
test 1586 -eq "$Wc_c" ||
	echo 'bdftools/bdftops-1.1/README: original size 1586, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bdftops-1.1/patchlevel.h ==============
if test -f 'bdftools/bdftops-1.1/patchlevel.h' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bdftops-1.1/patchlevel.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bdftops-1.1/patchlevel.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bdftops-1.1/patchlevel.h' &&
#define patchlevel 1
X
SHAR_EOF
chmod 0664 bdftools/bdftops-1.1/patchlevel.h ||
echo 'restore of bdftools/bdftops-1.1/patchlevel.h failed'
Wc_c="`wc -c < 'bdftools/bdftops-1.1/patchlevel.h'`"
test 22 -eq "$Wc_c" ||
	echo 'bdftools/bdftops-1.1/patchlevel.h: original size 22, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bdftops-1.1/Imakefile ==============
if test -f 'bdftools/bdftops-1.1/Imakefile' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bdftops-1.1/Imakefile (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bdftops-1.1/Imakefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bdftops-1.1/Imakefile' &&
#
# Make file for the BDF font to Postscript font converter
#
# If TOP is incorrectly defined, uncomment and change the following
# line to point at the X11 distribution source.
X
#        TOP = /usr/local/src/X11/mit
X
X      SRCS  = bdftops.c
X      OBJS  = bdftops.o
X   INCLUDES = -I.
X   PROGRAM  = bdftops
X
ComplexProgramTarget(bdftops)
SHAR_EOF
chmod 0664 bdftools/bdftops-1.1/Imakefile ||
echo 'restore of bdftools/bdftops-1.1/Imakefile failed'
Wc_c="`wc -c < 'bdftools/bdftops-1.1/Imakefile'`"
test 337 -eq "$Wc_c" ||
	echo 'bdftools/bdftops-1.1/Imakefile: original size 337, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bdftops-1.1/Makefile ==============
if test -f 'bdftools/bdftops-1.1/Makefile' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bdftops-1.1/Makefile (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bdftops-1.1/Makefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bdftops-1.1/Makefile' &&
# Makefile generated by imake - do not edit!
# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
#
# The cpp used on this machine replaces all newlines and multiple tabs and
# spaces in a macro expansion with a single space.  Imake tries to compensate
# for this, but is not always successful.
#
X
###########################################################################
# Makefile generated from "Imake.tmpl" and </tmp/IIf.a09492>
# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
#
# Platform-specific parameters may be set in the appropriate .cf
# configuration files.  Site-wide parameters may be set in the file
# site.def.  Full rebuilds are recommended if any parameters are changed.
#
# If your C preprocessor doesn't define any unique symbols, you'll need
# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
# "make Makefile", "make Makefiles", or "make World").
#
# If you absolutely can't get imake to work, you'll need to set the
# variables at the top of each Makefile as well as the dependencies at the
# bottom (makedepend will do this automatically).
#
X
###########################################################################
# platform-specific configuration parameters - edit sun.cf to change
X
# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
# operating system:  SunOS 4.1
X
###########################################################################
# site-specific configuration parameters - edit site.def to change
X
# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
X
X            SHELL = /bin/sh
X
X              TOP = /usr/local/src/X11/mit
X      CURRENT_DIR = .
X
X               AR = ar clq
X  BOOTSTRAPCFLAGS =
X               CC = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X             MAKE = make
X               MV = mv
X               CP = cp
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X     STD_INCLUDES =
X  STD_CPP_DEFINES =
X      STD_DEFINES =
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF = -DSHAREDCODE
X         SHLIBDEF = -DSUNSHLIB
X
X    PROTO_DEFINES =
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755
X     INSTLIBFLAGS = -m 0664
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 4755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(INCROOT)
X
X      CDEBUGFLAGS = -O
X        CCOPTIONS =
X      COMPATFLAGS = -DXAW_BC
X
X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
X   LDCOMBINEFLAGS = -X -r
X
X        MACROFILE = sun.cf
X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
X			$(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
X			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
X
###########################################################################
# X Window System Build Parameters
# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
###########################################################################
# X Window System make variables; this need to be coordinated with rules
# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X          PATHSEP = /
X        USRLIBDIR = /usr/local/lib/X11R4
X           BINDIR = /usr/local/bin/X11R4
X          INCROOT = /usr/include/X11
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = $(DESTDIR)/usr/adm
X           LIBDIR = /usr/local/lib/X11R4
X        CONFIGDIR = $(LIBDIR)/config
X       LINTLIBDIR = $(USRLIBDIR)/lint
X
X          FONTDIR = /usr/local/lib/X11R4/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = $(LIBDIR)/xdm
X           AWMDIR = $(LIBDIR)/awm
X           TWMDIR = $(LIBDIR)/twm
X           GWMDIR = $(LIBDIR)/gwm
X          MANPATH = $(DESTDIR)/usr/local/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = /usr/local/man/man1
X        LIBMANDIR = $(MANSOURCEPATH)3X
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X        SOXLIBREV = 4.2
X          SOXTREV = 4.0
X         SOXAWREV = 4.0
X        SOOLDXREV = 4.0
X         SOXMUREV = 4.0
X        SOXEXTREV = 4.0
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = imake
X           DEPEND = makedepend
X              RGB = rgb
X            FONTC = bdftosnf
X        MKFONTDIR = mkfontdir
X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
X
X        CONFIGSRC = $(TOP)/config
X        CLIENTSRC = $(TOP)/clients
X          DEMOSRC = $(TOP)/demos
X           LIBSRC = $(TOP)/lib
X          FONTSRC = $(TOP)/fonts
X       INCLUDESRC = $(TOP)/X11
X        SERVERSRC = $(TOP)/server
X          UTILSRC = $(TOP)/util
X        SCRIPTSRC = $(UTILSRC)/scripts
X       EXAMPLESRC = $(TOP)/examples
X       CONTRIBSRC = $(TOP)/../contrib
X           DOCSRC = $(TOP)/doc
X           RGBSRC = $(TOP)/rgb
X        DEPENDSRC = $(UTILSRC)/makedepend
X         IMAKESRC = $(CONFIGSRC)
X         XAUTHSRC = $(LIBSRC)/Xau
X          XLIBSRC = $(LIBSRC)/X
X           XMUSRC = $(LIBSRC)/Xmu
X       TOOLKITSRC = $(LIBSRC)/Xt
X       AWIDGETSRC = $(LIBSRC)/Xaw
X       OLDXLIBSRC = $(LIBSRC)/oldX
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X     EXTENSIONSRC = $(TOP)/extensions
X
X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
X     EXTENSIONLIB =  -lXext
X
X          DEPXLIB = $(DEPEXTENSIONLIB)
X             XLIB = $(EXTENSIONLIB) -lX11
X
X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
X         XAUTHLIB =  -lXau
X
X        DEPXMULIB =
X           XMULIB = -lXmu
X
X       DEPOLDXLIB =
X          OLDXLIB = -loldX
X
X      DEPXTOOLLIB =
X         XTOOLLIB = -lXt
X
X        DEPXAWLIB =
X           XAWLIB = -lXaw
X
X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
###########################################################################
# Imake rules for building libraries, programs, scripts, and data files
# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
X
###########################################################################
# start of Imakefile
X
#
# Make file for the BDF font to Postscript font converter
#
# If TOP is incorrectly defined, uncomment and change the following
# line to point at the X11 distribution source.
X
#        TOP = /usr/local/src/X11/mit
X
X      SRCS  = bdftops.c
X      OBJS  = bdftops.o
X   INCLUDES = -I.
X   PROGRAM  = bdftops
X
X PROGRAM = bdftops
X
all:: bdftops
X
bdftops: $(OBJS)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
X
saber_bdftops:
X	#load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
osaber_bdftops:
X	#load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
install:: bdftops
X	$(INSTALL) -c $(INSTPGMFLAGS)   bdftops $(BINDIR)
X
install.man:: bdftops.man
X	$(INSTALL) -c $(INSTMANFLAGS) bdftops.man $(MANDIR)/bdftops.1
X
depend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
lint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
lint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
clean::
X	$(RM) $(PROGRAM)
X
###########################################################################
# common rules for all Makefiles - do not edit
X
emptyrule::
X
clean::
X	$(RM_CMD) \#*
X
Makefile::
X	-@if [ -f Makefile ]; then \
X	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
tags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
saber:
X	#load $(ALLDEFINES) $(SRCS)
X
osaber:
X	#load $(ALLDEFINES) $(OBJS)
X
###########################################################################
# empty rules for directories that do not have SUBDIRS - do not edit
X
install::
X	@echo "install in $(CURRENT_DIR) done"
X
install.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
Makefiles::
X
includes::
X
###########################################################################
# dependencies generated by makedepend
X
SHAR_EOF
chmod 0664 bdftools/bdftops-1.1/Makefile ||
echo 'restore of bdftools/bdftops-1.1/Makefile failed'
Wc_c="`wc -c < 'bdftools/bdftops-1.1/Makefile'`"
test 9117 -eq "$Wc_c" ||
	echo 'bdftools/bdftops-1.1/Makefile: original size 9117, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bintobdf-1.0/Imakefile ==============
if test ! -d 'bdftools/bintobdf-1.0'; then
    echo 'x - creating directory bdftools/bintobdf-1.0'
    mkdir 'bdftools/bintobdf-1.0'
fi
if test -f 'bdftools/bintobdf-1.0/Imakefile' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bintobdf-1.0/Imakefile (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bintobdf-1.0/Imakefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bintobdf-1.0/Imakefile' &&
#
# Make file for the binary to BDF font converter
#
X
X      SRCS  = bintobdf.c
X      OBJS  = bintobdf.o
X   INCLUDES = -I. -I$(SERVERSRC)/include -I$(BDFTOSNFSRC)
X   PROGRAM  = bintobdf
X
ComplexProgramTarget(bintobdf)
SHAR_EOF
chmod 0664 bdftools/bintobdf-1.0/Imakefile ||
echo 'restore of bdftools/bintobdf-1.0/Imakefile failed'
Wc_c="`wc -c < 'bdftools/bintobdf-1.0/Imakefile'`"
test 217 -eq "$Wc_c" ||
	echo 'bdftools/bintobdf-1.0/Imakefile: original size 217, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bintobdf-1.0/bintobdf.c ==============
if test -f 'bdftools/bintobdf-1.0/bintobdf.c' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bintobdf-1.0/bintobdf.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bintobdf-1.0/bintobdf.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bintobdf-1.0/bintobdf.c' &&
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include "bintobdf.h"
#include "patchlevel.h"
X
char *program;               /* This program's name.                    */
char *fontname = NULL;       /* BDF font name.                          */
int rev_bytes_out = FALSE;   /* Reverse the character's bytes.          */
int size = 16;               /* Default to 16x16 font.                  */
int bytes_per_char = 0;      /* Bytes needed for each char.             */
int bytes_skipped = 0;       /* Number of initial bytes to be skipped.  */
int encoding_start = 0xa1a1; /* Initial encoding start.                 */
int chars_per_row = 0x5e;    /* Number characters per row in font.      */
int gen_n_chars = 0;         /* Only generate n charaters.              */
int xoff = 0;                /* Character's x offset.                   */
int yoff = -2;               /* Character's y offset.                   */
int default_char = 0xa1a1;   /* Default char of BDF font.               */
int total_chars = 0;         /* Total number of chars in input file.    */
X
/*
X * Set the default architecture specific bit and byte orderings for bitmaps.
X */
int bitOrder  = DEFAULTBITORDER,
X    byteOrder = DEFAULTBYTEORDER,
X    scanUnit  = DEFAULTSCANUNIT;
X
/*
X * Next three functions for adjusting bitmaps for different architectures.
X */
static void
invertbits(buf, count)
unsigned char *buf;
int count;
{
X    int i, n, m;
X    unsigned char c, oc;
X
X    for ( i = 0; i < count; i++ ) {
X        c = buf[i];
X        oc = 0;
X        for (n=0, m=7; n < 8; n++, m--) {
X            oc |= ((c >> n) & 1) << m;
X        }
X        buf[i] = oc;
X    }
}
X
static void
invert2(buf, count)
unsigned char *buf;
int count;
{
X    int i;
X    unsigned char c;
X
X    for ( i = 0; i < count; i += 2) {
X        c = buf[i];
X        buf[i] = buf[i+1];
X        buf[i+1] = c;
X    }
}
X
static void
invert4(buf, count)
unsigned char *buf;
int count;
{
X    int i;
X    unsigned char c;
X
X    for (i = 0; i < count; i += 4) {
X        c = buf[i];
X        buf[i] = buf[i+3];
X        buf[i+3] = c;
X        c = buf[i+1];
X        buf[i+1] = buf[i+2];
X        buf[i+2] = c;
X    }
}
X
#define my_abs(x) (((x) < 0) ? -(x) : (x))
X
void
genbdf(infile, outfile)
FILE *infile, *outfile;
{
X    time_t clock;
X    struct stat fsize;
X
X    int i, row, column, row_start, column_start;
X    int start, end, inc;
X    int swidth, dwidth;
X    long int fsz, nfsz;
X    int done;
X    int bpcl, count, char_count;
X    double resval;
X
X    unsigned char *in_buf;
X
X    time(&clock);
X    fprintf(outfile, "STARTFONT 2.1\n");
X    fprintf(outfile, "COMMENT GENERATED BY \"bin2bdf %d.%d\"\n",
X            BINTOBDFVERSION, patchlevel);
X    fprintf(outfile, "COMMENT AUTHOR %s\n", AUTHOR_STRING);
X    fprintf(outfile, "COMMENT DATE %s", ctime(&clock));
X    fprintf(outfile, "COMMENT\n");
X    fprintf(outfile, "FONT %s\n", fontname);
X    fprintf(outfile, "SIZE %d %d %d\n", size, DEFAULTXRES, DEFAULTYRES);
X    fprintf(outfile, "FONTBOUNDINGBOX %d %d %d %d\n", size, size, xoff, yoff);
X    fprintf(outfile, "STARTPROPERTIES 4\n");
X    fprintf(outfile, "COPYRIGHT \"Public Domain\"\n");
X    fprintf(outfile, "DEFAULT_CHAR %d\n", default_char);
X    fprintf(outfile, "FONT_ASCENT %d\n", size + yoff);
X    fprintf(outfile, "FONT_DESCENT %d\n", my_abs(yoff));
X    fprintf(outfile, "ENDPROPERTIES\n");
X
X    if (fstat(fileno(infile), &fsize) < 0) {
X        fprintf(stderr, "%s: stat error on input file\n", program);
X        fclose(infile);
X        exit(-1);
X    }
X
X    fsz = nfsz = ((long int)fsize.st_size) - bytes_skipped;
X
X    if (bytes_skipped) {
X        if (fseek(infile, bytes_skipped, 0L) < 0) {
X            fprintf(stderr, "%s: fseek problem on input file.\n", program);
X            fclose(infile);
X            if (outfile != stdout)
X              fclose(outfile);
X        }
X    }
X
X    while(fsz % size) fsz--;
X    if ((nfsz - fsz) != 0) {
X        fprintf(stderr,
X                "%s: found odd number of bytes - skipping %d bytes forward.\n",
X                program, (nfsz - fsz));
X        if (fseek(infile, (nfsz - fsz), 1L) < 0) {
X            fprintf(stderr, "%s: fseek problem on input file.\n", program);
X            fclose(infile);
X            if (outfile != stdout)
X              fclose(outfile);
X        }
X    }
X
X    total_chars = fsz / bytes_per_char;
X    total_chars++;
X
X    if ((gen_n_chars == 0) || (gen_n_chars > total_chars))
X      gen_n_chars = total_chars;
X
X    resval = (((double)size)/1000.0) * (((double)DEFAULTXRES)/72.27);
X    swidth = (int)(((double)DEFAULTXRES)/resval) / 10;
X    dwidth = size;
X
X    fprintf(outfile, "CHARS %d\n", gen_n_chars);
X
X    row_start = (encoding_start >> 8) & 0xff;
X    column_start = encoding_start & 0xff;
X
X    row = row_start;
X    column = column_start;
X    done = FALSE;
X    bpcl = (size + 7) / 8;
X    in_buf = (unsigned char *)malloc(bytes_per_char * sizeof(unsigned char));
X
X    char_count = 0;
X    while(char_count < gen_n_chars && !feof(infile)) {
X        if ((column - column_start) == chars_per_row) {
X            column = column_start;
X            row++;
X        }
X
X        fprintf(outfile, "STARTCHAR %02x%02x\n", row & 0xff, column & 0xff);
X        fprintf(outfile, "ENCODING %d\n", ((row << 8) | column));
X        fprintf(outfile, "SWIDTH %d 0\n", swidth);
X        fprintf(outfile, "DWIDTH %d 0\n", size);
X        fprintf(outfile, "BBX %d %d %d %d\n", size, size, xoff, yoff);
X        fprintf(outfile, "BITMAP\n");
X
X
X        if (fread(in_buf, 1, bytes_per_char, infile) != bytes_per_char) {
X            if (!feof(infile)) {
X                fprintf(stderr,
X                        "%s: missing some bytes on the end of input file\n",
X                        program);
X                fclose(infile);
X                if (outfile != stdout)
X                  fclose(outfile);
X                exit(-1);
X            }
X        }
X
X        if (bitOrder == LSBFirst)
X          invertbits(in_buf, bytes_per_char);
X        if (bitOrder != byteOrder) {
X            if (scanUnit == 2)
X              invert2(in_buf, bytes_per_char);
X            else if (scanUnit == 4)
X              invert4(in_buf, bytes_per_char);
X        }
X
X        if (rev_bytes_out) {
X            start = bytes_per_char - 1;
X            end = inc = -1;
X        } else {
X            start = 0;
X            end = bytes_per_char;
X            inc = 1;
X        }
X
X        count = 0;
X        while (start != end) {
X            if (count == bpcl) {
X                putc('\n', outfile);
X                count = 0;
X            }
X            count++;
X            fprintf(outfile, "%02x", in_buf[start]);
X            start += inc;
X        }
X        fprintf(outfile, "\nENDCHAR\n");
X        column++;
X        char_count++;
X    }
X    fprintf(outfile, "ENDFONT\n");
}
X
char *
make_fontname(name)
char *name;
{
X    char *tmp_name, *ptr, *ptr1;
X    int len;
X
X    len = strlen(name) - 1;
X    ptr = ptr1 = name + len;
X    for (;*ptr && *ptr != DIR_SEP && ptr != name; ptr--) {}
X
X    if (!*ptr) {
X        fprintf(stderr, "%s: unexpected NULL in filename\n", program);
X        exit(-1);
X    }
X
X    for (;*ptr1 && *ptr1 != '.' && ptr1 != name; ptr1--) {}
X
X    if (ptr == name && ptr1 == name) {
X        tmp_name = (char *)malloc((len + 4) * sizeof(char));
X        sprintf(tmp_name, "%s%d", name, size);
X        return(tmp_name);
X    }
X
X    if (*ptr == DIR_SEP)
X      ptr++;
X
X    tmp_name = (char *)malloc((ptr1 - ptr + 5) * sizeof(char));
X    sprintf(tmp_name, "%.*s%d", (ptr1 - ptr), ptr, size);
X
X    return(tmp_name);
}
X
void
usage()
{
X    fprintf(stderr, "usage:  %s [-size #] [-skip #] [-cdefglmLMoruxy] ",
X            program);
X    fprintf(stderr, "infile\n");
X    exit(-1);
}
X
int
getint(str)
char *str;
{
X    if (!str)
X      usage();
X    return(atoi(str));
}
X
main(argc, argv)
int argc;
char **argv;
{
X    FILE *in = stdin, *out = stdout;
X    char next;
X
X    program = argv[0];
X    argc--;
X    *argv++;
X
X    if (!argc)
X      usage();
X
X    while(argc) {
X        if (argv[0][0] == '-') {
X            switch(argv[0][1]) {
X              case 'c':
X              case 'C':
X                argc--;
X                *argv++;
X                chars_per_row = getint(argv[0]);
X                break;
X              case 'd':
X              case 'D':
X                argc--;
X                *argv++;
X                default_char = getint(argv[0]);
X                break;
X              case 'e':
X              case 'E':
X                argc--;
X                *argv++;
X                encoding_start = getint(argv[0]);
X                break;
X              case 'f':
X              case 'F':
X                argc--;
X                *argv++;
X                if (argv[0])
X                  fontname = argv[0];
X                else
X                  usage();
X                break;
X              case 'g':
X              case 'G':
X                argc--;
X                *argv++;
X                gen_n_chars = getint(argv[0]);
X                break;
X              case 'L':
X                byteOrder = LSBFirst;
X                break;
X              case 'l':
X                bitOrder = LSBFirst;
X                break;
X              case 'M':
X                byteOrder = MSBFirst;
X                break;
X              case 'm':
X                bitOrder = MSBFirst;
X                break;
X              case 'o':
X              case 'O':
X                argc--;
X                *argv++;
X                if (argv[0]) {
X                    if (!(out = fopen(argv[0], "w+b"))) {
X                        fprintf(stderr, "%s: problem with output file %s\n",
X                                argv[0]);
X                        exit(-1);
X                    }
X                } else
X                  usage();
X                break;
X              case 'r':
X              case 'R':
X                rev_bytes_out = TRUE;
X                break;
X              case 's':
X              case 'S':
X                next = '\0';
X                switch(argv[0][2]) {
X                    /* Set char width to size by size bits. */
X                  case 'i':
X                  case 'I':
X                    argc--;
X                    *argv++;
X                    size = getint(argv[0]);
X                    break;
X                    /* Skip n bytes at beginning of file. */
X                  case 'k':
X                  case 'K':
X                    argc--;
X                    *argv++;
X                    bytes_skipped = getint(argv[0]);
X                    break;
X                  default:
X                    usage();
X                    break;
X                }
X                break;
X              case 'u':
X              case 'U':
X                argc--;
X                *argv++;
X                scanUnit = getint(argv[0]);
X                break;
X              case 'x':
X              case 'X':
X                argc--;
X                *argv++;
X                xoff = getint(argv[0]);
X                break;
X              case 'y':
X              case 'Y':
X                argc--;
X                *argv++;
X                yoff = atoi(argv[0]);
X                break;
X              default:
X                usage();
X                break;
X            }
X        } else {
X            if (fontname == NULL)
X              fontname = make_fontname(argv[0]);
X            
X            if (!(in = fopen(argv[0], "r+b"))) {
X                fprintf(stderr, "%s: problem with input file %s\n",
X                        program, argv[0]);
X                exit(-1);
X            }
X            bytes_per_char = ((size + 7) / 8) * size;
X            genbdf(in, out);
X            if (in != stdin)
X              fclose(in);
X            if (out != stdout)
X              fclose(out);
X        }
X        if (argc) {
X            argc--;
X            *argv++;
X        }
X    }
}
SHAR_EOF
chmod 0664 bdftools/bintobdf-1.0/bintobdf.c ||
echo 'restore of bdftools/bintobdf-1.0/bintobdf.c failed'
Wc_c="`wc -c < 'bdftools/bintobdf-1.0/bintobdf.c'`"
test 11688 -eq "$Wc_c" ||
	echo 'bdftools/bintobdf-1.0/bintobdf.c: original size 11688, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bintobdf-1.0/bintobdf.h ==============
if test -f 'bdftools/bintobdf-1.0/bintobdf.h' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bintobdf-1.0/bintobdf.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bintobdf-1.0/bintobdf.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bintobdf-1.0/bintobdf.h' &&
#ifndef _bintobdf_h
#define _bintobdf_h
X
#include <X11/Xos.h>
#include <X11/Xmd.h>
#include <X11/X.h>
#include <X11/Xproto.h>
X
#include "fontstruct.h"
#include "bdftosnf.h"
X
#define AUTHOR_STRING "mleisher@nmsu.edu (Mark Leisher)"
#define BINTOBDFVERSION 1
X
#define FALSE 0
#define TRUE  1
X
/* Make sure the directory separator is defined for loading fonts. */
X
#ifndef DIR_SEP
#define DIR_SEP '/'
#endif
X
/*
X * This is the x and y resolution the font was designed at.
X * Most of the time, these values are just guessed at for bitmapped
X * fonts.
X */
#ifndef DEFAULTXRES
#define DEFAULTXRES 100
#endif
X
#ifndef DEFAULTYRES
#define DEFAULTYRES 100
#endif
X
#endif /* _bintobdf_h */
SHAR_EOF
chmod 0664 bdftools/bintobdf-1.0/bintobdf.h ||
echo 'restore of bdftools/bintobdf-1.0/bintobdf.h failed'
Wc_c="`wc -c < 'bdftools/bintobdf-1.0/bintobdf.h'`"
test 680 -eq "$Wc_c" ||
	echo 'bdftools/bintobdf-1.0/bintobdf.h: original size 680, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bintobdf-1.0/bintobdf.man ==============
if test -f 'bdftools/bintobdf-1.0/bintobdf.man' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bintobdf-1.0/bintobdf.man (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bintobdf-1.0/bintobdf.man (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bintobdf-1.0/bintobdf.man' &&
.TH BINTOBDF 1 "Release 4" "X Version 11"
.SH NAME
bintobdf - Binary to BDF font converter for X11
.SH SYNOPSIS
.B "bintobdf"
[-c #] [-d #] [-e #] [-f name] [-g #] [-lmLM] [-o name] [-r] [-size #]
[-skip #] [-u #] [-x #] [-y #] bitmap-font-file
.SH DESCRIPTION
.PP
.B bintobdf
reads a raw bitmap font from the
specified file and writes an X11 Bitmap Distribution Format (BDF) to
standard output.
.SH OPTIONS
.TP 8
.B \-c #
The number following \fI-c\fP is the number of characters that will
appear in a row.  For instance, in the GB 2312-1980 and JIS X0208
encoding, there are 94 characters per row.  In the Big5 encoding,
there are 190 characters per row. (Default: 94)
.TP 8
.B \-d #
The number following \fI-d\fP will be the default character on the BDF
font.  (Default: \fIthe value for -e\fP)
.TP 8
.B \-e #
The number following \fI-e\fP will be the encoding value of the first
character in the BDF font.  For instance, the encoding starts at 41377
(0xa1a1) for GB 2312-1980, and the encoding starts at 8481 (0x2121) for
the JIS X0208 encoding.  The Big5 encoding starts at 41280 (0xa140).
.TP 8
.B \-f name
The string following \fI-f\fP will be the name used for the ``FONT''
entry of the BDF font. (Default: basename of the font concated with size)
.TP 8
.B \-g #
The number following \fI-g\fP indicates how many of the bitmap
characters to generate.  This is here for generating a limited number
of characters for testing purposes. (Default: calculated from raw
bitmap font file size and character size)
.TP 8
.B \-l
Force the bit order to least significant bit first.
.TP 8
.B \-m
Force the bit order to most significant bit first.
.TP 8
.B \-L
Force the byte order to least significant bit first.
.TP 8
.B \-M
Force the byte order to most significant bit first.
.TP 8
.B \-o name
Send the output to \fIname\fP instead of stdout.
.TP 8
.B \-r
Write each characters bytes in reverse order after they have been
adjusted for bit and byte order.
.TP 8
.B \-size #
The number following \fI-size\fP will be the width and height in bits
of each character. A lot of fonts that use two bytes per character are
either 16x16 or 24x24. (Default: 16)
.TP 8
.B \-skip #
The number that follows \fI-skip\fP will be the number of bytes
skipped at the beginning of the raw bitmap font file.  Occasionally, a
raw bitmap font file will have some sort of header information.
(Default: 0)
.TP 8
.B \-u #
The number that follows \fI-u\fP will be the scan unit for each
character's bitmap.  This value determines number of bytes that will
be swapped in setting bit and byte order of each character.  This
value shouldn't change for most Big<->Little Endian conversions.
If you are unsure if the target architecture needs this value changed,
check the \fBservermd.h\fP file in the X11 server source distribution.
(Default: 1)
.TP 8
.B \-x #
Set the X offset of the character in the BDF font.  For fonts that use
two bytes per character, a value of 0 usually looks alright. (Default: 0)
.TP 8
.B \-y #
Set the Y offset of the character in the BDF font.  In fonts that use
two bytes per character, a value of -2 usually looks alright. (Default: -2)
.SH "SEE ALSO"
XX(1), Xserver(1), bdftosnf(1), snftobdf(1), bdftops(1)
.br
"Bitmap Distribution Format 2.1"
.br
"X Logical Font Description Conventions"
.SH AUTHOR
Internet: mleisher@nmsu.edu   Bitnet: mleisher@nmsu.bitnet
.br
Mark Leisher
.br
Computing Research Lab
.br
New Mexico State University
.br
Las Cruces, NM 88003
.br
(505) 646-5711
X
SHAR_EOF
chmod 0664 bdftools/bintobdf-1.0/bintobdf.man ||
echo 'restore of bdftools/bintobdf-1.0/bintobdf.man failed'
Wc_c="`wc -c < 'bdftools/bintobdf-1.0/bintobdf.man'`"
test 3475 -eq "$Wc_c" ||
	echo 'bdftools/bintobdf-1.0/bintobdf.man: original size 3475, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bintobdf-1.0/patchlevel.h ==============
if test -f 'bdftools/bintobdf-1.0/patchlevel.h' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bintobdf-1.0/patchlevel.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bintobdf-1.0/patchlevel.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bintobdf-1.0/patchlevel.h' &&
#define patchlevel 0
SHAR_EOF
chmod 0664 bdftools/bintobdf-1.0/patchlevel.h ||
echo 'restore of bdftools/bintobdf-1.0/patchlevel.h failed'
Wc_c="`wc -c < 'bdftools/bintobdf-1.0/patchlevel.h'`"
test 21 -eq "$Wc_c" ||
	echo 'bdftools/bintobdf-1.0/patchlevel.h: original size 21, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/bintobdf-1.0/README ==============
if test -f 'bdftools/bintobdf-1.0/README' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/bintobdf-1.0/README (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/bintobdf-1.0/README (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/bintobdf-1.0/README' &&
--------------------------------------------------------------------
Copyright (C) 1990 Mark Leisher.
X
Author: Mark Leisher (mleisher@nmsu.edu)
X
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
X
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
X
A copy of the GNU General Public License can be obtained from this
program's author (send electronic mail to mleisher@nmsu.edu) or from
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
02139, USA.
--------------------------------------------------------------------
X
This program converts raw bitmap fonts into BDF format fonts.  It
allows for things like skipping headers on the input font and doing
bit and byte adjustments dependent on architecture.
X
I wrote bintobdf because I was tired of hacking out a new utility
every time I wanted to convert a raw bitmap font into a BDF font.
X
Bintobdf is designed primarily for fiddling with fonts that have a
large number of characters (i.e. some of the Oriental fonts), but it
can easily be used for just about any size raw bitmap font.  The only
real "gotcha" in the program is the assumption that the font's
characters are square.  This is hardcoded, so it would have to be
changed for other types of fonts.
X
Please send bug reports, enhancements, etc. to:
Internet: mleisher@nmsu.edu
Bitnet  : mleisher@nmsu.bitnet
SHAR_EOF
chmod 0664 bdftools/bintobdf-1.0/README ||
echo 'restore of bdftools/bintobdf-1.0/README failed'
Wc_c="`wc -c < 'bdftools/bintobdf-1.0/README'`"
test 1685 -eq "$Wc_c" ||
	echo 'bdftools/bintobdf-1.0/README: original size 1685, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/snftobdf-1.4/Imakefile ==============
if test ! -d 'bdftools/snftobdf-1.4'; then
    echo 'x - creating directory bdftools/snftobdf-1.4'
    mkdir 'bdftools/snftobdf-1.4'
fi
if test -f 'bdftools/snftobdf-1.4/Imakefile' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/snftobdf-1.4/Imakefile (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/snftobdf-1.4/Imakefile (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/snftobdf-1.4/Imakefile' &&
#
# Make file for the SNF to BDF font compiler
#
# If TOP is incorrectly defined, uncomment and change the following
# line to point at the X11 distribution source.
X
#        TOP = /usr/local/src/X11/mit
X
X      SRCS  = snftobdf.c input.c output.c
X      OBJS  = snftobdf.o input.o output.o
X   INCLUDES = -I. -I$(SERVERSRC)/include -I$(SERVERSRC)/ddx/snf \
X              -I$(BDFTOSNFSRC)
X   PROGRAM  = snftobdf
X
ComplexProgramTarget(snftobdf)
SHAR_EOF
chmod 0664 bdftools/snftobdf-1.4/Imakefile ||
echo 'restore of bdftools/snftobdf-1.4/Imakefile failed'
Wc_c="`wc -c < 'bdftools/snftobdf-1.4/Imakefile'`"
test 441 -eq "$Wc_c" ||
	echo 'bdftools/snftobdf-1.4/Imakefile: original size 441, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= bdftools/snftobdf-1.4/MANIFEST ==============
if test -f 'bdftools/snftobdf-1.4/MANIFEST' -a X"$1" != X"-c"; then
	echo 'x - skipping bdftools/snftobdf-1.4/MANIFEST (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting bdftools/snftobdf-1.4/MANIFEST (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'bdftools/snftobdf-1.4/MANIFEST' &&
MANIFEST
SHAR_EOF
true || echo 'restore of bdftools/snftobdf-1.4/MANIFEST failed'
fi
echo 'End of bdftools/part part 1'
echo 'File bdftools/snftobdf-1.4/MANIFEST is continued in part 2'
echo 2 > _shar_seq_.tmp
exit 0