diff options
author | wl <wl> | 2004-11-25 08:08:33 +0000 |
---|---|---|
committer | wl <wl> | 2004-11-25 08:08:33 +0000 |
commit | 8a5994ff40d323c2662ee9a9238d7e85fe509186 (patch) | |
tree | 47d148a38d7e4fa1065a649767feb6d44a845f3c /src/utils | |
parent | de829747a56c40437a35bcb26dea130ea45211b5 (diff) | |
download | groff-8a5994ff40d323c2662ee9a9238d7e85fe509186.tar.gz |
* src/utils/xtotroff/xtotroff.c: Reformat to be similar to other
groff source files.
Include config.h.
Include limits.h.
Remove X_NOT_STDC_ENV conditional.
(Version_string, program_name): New global variables.
(groff_flag): Removed.
(MapFont): Updated.
(usage): Take a stream as argument.
Use `program_name'.
Update all callers.
(main): Add `long_options' array for `--help' and `--version'.
Make `-g' a dummy option.
Handle `-v' and unknown options.
Remove unused `position' variable.
* src/utils/xtotroff/Makefile.sub (MAN1): Define.
(XLIBS): Add LIBGROFF.
* src/utils/xtotroff/xtotroff.man, src/utils/xtotroff/Makefile.in:
New files.
* src/devices/xditview/Dvi.c (default_font_map): Split into three
parts to avoid compiler warning.
(resources): Don't initialize with `default_font_map'.
(ClassInitialize): Initialize first element of `resources'.
* src/devices/xditview/Makefile.sub (devdir, xtotroff, DPIS, fonts):
Removed.
* src/utils/lkbib/lkbib.man, src/utils/lookbib/lookbib.man,
src/utils/pfbtops/pfbtops.man: Revised, updated.
* configure.ac: Generate src/utils/xtotroff/Makefile.
* configure: Regenerated.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/lkbib/lkbib.man | 36 | ||||
-rw-r--r-- | src/utils/lookbib/lookbib.man | 27 | ||||
-rw-r--r-- | src/utils/pfbtops/pfbtops.man | 21 | ||||
-rw-r--r-- | src/utils/xtotroff/Makefile.in | 62 | ||||
-rw-r--r-- | src/utils/xtotroff/Makefile.sub | 4 | ||||
-rw-r--r-- | src/utils/xtotroff/xtotroff.c | 529 | ||||
-rw-r--r-- | src/utils/xtotroff/xtotroff.man | 109 |
7 files changed, 510 insertions, 278 deletions
diff --git a/src/utils/lkbib/lkbib.man b/src/utils/lkbib/lkbib.man index 81067d13..29831ee8 100644 --- a/src/utils/lkbib/lkbib.man +++ b/src/utils/lkbib/lkbib.man @@ -1,5 +1,5 @@ .ig -Copyright (C) 1989-2000, 2001 Free Software Foundation, Inc. +Copyright (C) 1989-2000, 2001, 2004 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -16,17 +16,23 @@ versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. .. -.ds g \" empty -.ds G \" empty +. +. .\" Like TP, but if specified indent is more than half .\" the current line-length - indent, use the default indent. .de Tp -.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP -.el .TP "\\$1" +. ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP +. el .TP "\\$1" .. +. +. .TH LKBIB @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +. +. .SH NAME lkbib \- search bibliographic databases +. +. .SH SYNOPSIS .B lkbib [ @@ -42,13 +48,16 @@ lkbib \- search bibliographic databases .BI \-t n ] .IR key \|.\|.\|. +. .PP It is possible to have whitespace between a command line option and its parameter. +. +. .SH DESCRIPTION .B lkbib searches bibliographic databases for references that contain the keys -.IR key \|.\|.\|. +.IR key \|.\|.\|.\& and prints any references found on the standard output. .B lkbib will search any databases given by @@ -68,10 +77,13 @@ created by .BR @g@indxbib (@MAN1EXT@) exists, then it will be searched instead; each index can cover multiple databases. +. +. .SH OPTIONS .TP .B \-v Print the version number. +. .TP .BI \-p filename Search @@ -79,11 +91,13 @@ Search Multiple .B \-p options can be used. +. .TP .BI \-i string When searching files for which no index exists, ignore the contents of fields whose names are in .IR string . +. .TP .BI \-t n Only require the first @@ -91,19 +105,27 @@ Only require the first characters of keys to be given. Initially .I n -is 6. +is\~6. +. +. .SH ENVIRONMENT .TP \w'\fBREFER'u+2n .SB REFER Default database. +. +. .SH FILES .Tp \w'\fB@DEFAULT_INDEX@'u+2n .B @DEFAULT_INDEX@ Default database to be used if the .SB REFER environment variable is not set. +. +.TP .IB filename @INDEX_SUFFIX@ Index files. +. +. .SH "SEE ALSO" .BR @g@refer (@MAN1EXT@), .BR @g@lookbib (@MAN1EXT@), diff --git a/src/utils/lookbib/lookbib.man b/src/utils/lookbib/lookbib.man index 3d8ba440..baade0fd 100644 --- a/src/utils/lookbib/lookbib.man +++ b/src/utils/lookbib/lookbib.man @@ -1,5 +1,5 @@ .ig -Copyright (C) 1989-2000, 2001 Free Software Foundation, Inc. +Copyright (C) 1989-2000, 2001, 2004 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -16,9 +16,15 @@ versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. .. +. +. .TH @G@LOOKBIB @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +. +. .SH NAME @g@lookbib \- search bibliographic databases +. +. .SH SYNOPSIS .B @g@lookbib [ @@ -31,14 +37,19 @@ the original English. .BI \-t n ] .IR filename \|.\|.\|. +. .PP It is possible to have whitespace between a command line option and its parameter. +. +. .SH DESCRIPTION -@g@lookbib prints a prompt on the standard error (unless the standard input is not a terminal), +.B @g@lookbib +prints a prompt on the standard error (unless the standard input is not +a terminal), reads from the standard input a line containing a set of keywords, searches the bibliographic databases -.IR filename \|.\|.\|. +.IR filename \|.\|.\|.\& for references containing those keywords, prints any references found on the standard output, and repeats this process until the end of input. @@ -51,15 +62,19 @@ created by .BR @g@indxbib (@MAN1EXT@) exists, then it will be searched instead; each index can cover multiple databases. +. +. .SH OPTIONS .TP .B \-v Print the version number. +. .TP .BI \-i string When searching files for which no index exists, ignore the contents of fields whose names are in .IR string . +. .TP .BI \-t n Only require the first @@ -67,11 +82,15 @@ Only require the first characters of keys to be given. Initially .I n -is 6. +is\~6. +. +. .SH FILES .TP \w'\fIfilename\fB@INDEX_SUFFIX@'u+2n .IB filename @INDEX_SUFFIX@ Index files. +. +. .SH "SEE ALSO" .BR @g@refer (@MAN1EXT@), .BR lkbib (@MAN1EXT@), diff --git a/src/utils/pfbtops/pfbtops.man b/src/utils/pfbtops/pfbtops.man index 627e5c5e..c97a2976 100644 --- a/src/utils/pfbtops/pfbtops.man +++ b/src/utils/pfbtops/pfbtops.man @@ -1,5 +1,5 @@ .ig -Copyright (C) 1989-1995, 2001, 2003 Free Software Foundation, Inc. +Copyright (C) 1989-1995, 2001, 2003, 2004 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -16,14 +16,25 @@ versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. .. +. +. .TH PFBTOPS @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +. +. .SH NAME pfbtops \- translate a PostScript font in .pfb format to ASCII +. +. .SH SYNOPSIS .B pfbtops [ +.B \-v +] +[ .I pfb_file ] +. +. .SH DESCRIPTION .B pfbtops translates a PostScript font in @@ -37,10 +48,18 @@ The ASCII format PostScript font will be written on the standard output. PostScript fonts for MS-DOS are normally supplied in .B .pfb format. +. .LP The resulting ASCII format PostScript font can be used with groff. It must first be listed in .BR @FONTDIR@/devps/download . +. +.SH OPTIONS +.TP +.B \-v +Print the version number. +. +. .SH "SEE ALSO" .BR grops (@MAN1EXT@) . diff --git a/src/utils/xtotroff/Makefile.in b/src/utils/xtotroff/Makefile.in new file mode 100644 index 00000000..6aaaf489 --- /dev/null +++ b/src/utils/xtotroff/Makefile.in @@ -0,0 +1,62 @@ +# Copyright (C) 2004 +# Free Software Foundation, Inc. +# Written by James Clark (jjc@jclark.com) +# +# This file is part of groff. +# +# groff 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 2, or (at your option) any later +# version. +# +# groff 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. +# +# You should have received a copy of the GNU General Public License along +# with groff; see the file COPYING. If not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +builddir=@abs_builddir@ +top_srcdir=@abs_top_srcdir@ +top_builddir=@abs_top_builddir@ +SHELL=@SHELL@ + +devdir=$(top_builddir)/font +driverdir=$(top_srcdir)/src/devices/xditview +mkinstalldirs=$(SHELL) $(top_srcdir)/mkinstalldirs + +xtotroff=$(builddir)/xtotroff +DPIS=75 100 + +all: + @echo "Say \`make fonts' to generate fonts for gxditview." + +fonts: $(xtotroff) $(driverdir)/DESC.in $(driverdir)/FontMap + fonts=`sed -e 's/[ ].*//' $(driverdir)/FontMap`; \ + for dpi in $(DPIS); do \ + echo Making devX$$dpi; \ + test -d $(devdir)/devX$$dpi || \ + $(mkinstalldirs) $(devdir)/devX$$dpi; \ + rm -f $(devdir)/devX$$dpi/DESC; \ + sed -e "s/res 75/res $$dpi/" $(driverdir)/DESC.in \ + >$(devdir)/devX$$dpi/DESC; \ + (cd $(devdir)/devX$$dpi; \ + rm -f Makefile.sub; \ + echo DEV=X$$dpi >Makefile.sub; \ + echo DEVFILES=DESC $$fonts >>Makefile.sub; \ + $(xtotroff) -r $$dpi -s 10 $(driverdir)/FontMap); \ + echo Making devX$$dpi-12; \ + test -d $(devdir)/devX$$dpi-12 || \ + $(mkinstalldirs) $(devdir)/devX$$dpi-12; \ + rm -f $(devdir)/devX$$dpi-12/DESC; \ + sed -e "s/res 75/res $$dpi/" \ + -e 's/unitwidth 10/unitwidth 12/' $(driverdir)/DESC.in \ + >$(devdir)/devX$$dpi-12/DESC; \ + (cd $(devdir)/devX$$dpi-12; \ + rm -f Makefile.sub; \ + echo DEV=X$$dpi-12 >Makefile.sub; \ + echo DEVFILES=DESC $$fonts >>Makefile.sub; \ + $(xtotroff) -r $$dpi -s 12 $(driverdir)/FontMap); \ + done diff --git a/src/utils/xtotroff/Makefile.sub b/src/utils/xtotroff/Makefile.sub index 6710a8a9..fc0d76a5 100644 --- a/src/utils/xtotroff/Makefile.sub +++ b/src/utils/xtotroff/Makefile.sub @@ -1,7 +1,7 @@ PROG=xtotroff$(EXEEXT) -# MAN1=xtotroff.n +MAN1=xtotroff.n MLIB=$(LIBM) -XLIBS=$(LIBXUTIL) +XLIBS=$(LIBXUTIL) $(LIBGROFF) EXTRA_CFLAGS=$(X_CFLAGS) EXTRA_LDFLAGS=$(X_LIBS) $(X_PRE_LIBS) -lXaw -lXt -lX11 $(X_EXTRA_LIBS) OBJS=xtotroff.$(OBJEXT) diff --git a/src/utils/xtotroff/xtotroff.c b/src/utils/xtotroff/xtotroff.c index b3d5b02e..3265596f 100644 --- a/src/utils/xtotroff/xtotroff.c +++ b/src/utils/xtotroff/xtotroff.c @@ -4,291 +4,292 @@ * convert X font metrics into troff font metrics */ -#include <X11/Xlib.h> -#include <stdio.h> -#include <ctype.h> -#include <unistd.h> -#include <stdlib.h> -#include <getopt.h> -#include <string.h> -#include <fcntl.h> -#include "XFontName.h" -#include "DviChar.h" - -#ifdef X_NOT_STDC_ENV -char *malloc(); -#else -#include <stdlib.h> +#ifdef HAVE_CONFIG_H +#include <config.h> #endif -#define charWidth(fi,c) ((fi)->per_char[(c) - (fi)->min_char_or_byte2].width) -#define charHeight(fi,c) ((fi)->per_char[(c) - (fi)->min_char_or_byte2].ascent) -#define charDepth(fi,c) ((fi)->per_char[(c) - (fi)->min_char_or_byte2].descent) -#define charLBearing(fi,c) ((fi)->per_char[(c) - (fi)->min_char_or_byte2].lbearing) -#define charRBearing(fi,c) ((fi)->per_char[(c) - (fi)->min_char_or_byte2].rbearing) - -Display *dpy; -int groff_flag = 0; -unsigned resolution = 75; -unsigned point_size = 10; - -int charExists (XFontStruct *fi, int c) +#include <X11/Xlib.h> +#include <stdio.h> +#include <ctype.h> +#include <unistd.h> +#include <stdlib.h> +#include <getopt.h> +#include <string.h> +#include <fcntl.h> +#include <limits.h> +#include "XFontName.h" +#include "DviChar.h" + +#define charWidth(fi,c) \ + ((fi)->per_char[(c) - (fi)->min_char_or_byte2].width) +#define charHeight(fi,c) \ + ((fi)->per_char[(c) - (fi)->min_char_or_byte2].ascent) +#define charDepth(fi,c) \ + ((fi)->per_char[(c) - (fi)->min_char_or_byte2].descent) +#define charLBearing(fi,c) \ + ((fi)->per_char[(c) - (fi)->min_char_or_byte2].lbearing) +#define charRBearing(fi,c) \ + ((fi)->per_char[(c) - (fi)->min_char_or_byte2].rbearing) + +extern const char *Version_string; +static char *program_name; + +Display *dpy; +unsigned resolution = 75; +unsigned point_size = 10; + +int charExists(XFontStruct * fi, int c) { - XCharStruct *p; - - /* `c' is always >= 0 */ - if ((unsigned int)c < fi->min_char_or_byte2 - || (unsigned int)c > fi->max_char_or_byte2) - return 0; - p = fi->per_char + (c - fi->min_char_or_byte2); - return (p->lbearing != 0 || p->rbearing != 0 || p->width != 0 - || p->ascent != 0 || p->descent != 0 || p->attributes != 0); + XCharStruct *p; + + /* `c' is always >= 0 */ + if ((unsigned int) c < fi->min_char_or_byte2 + || (unsigned int) c > fi->max_char_or_byte2) + return 0; + p = fi->per_char + (c - fi->min_char_or_byte2); + return p->lbearing != 0 || p->rbearing != 0 || p->width != 0 + || p->ascent != 0 || p->descent != 0 || p->attributes != 0; } /* Canonicalize the font name by replacing scalable parts by *s. */ -static int -CanonicalizeFontName (char *font_name, char *canon_font_name) +static int CanonicalizeFontName(char *font_name, char *canon_font_name) { - unsigned int attributes; - XFontName parsed; - - if (!XParseFontName(font_name, &parsed, &attributes)) { - fprintf (stderr, "not a standard name: %s\n", font_name); - return 0; - } - - attributes &= ~(FontNamePixelSize|FontNameAverageWidth - |FontNamePointSize - |FontNameResolutionX|FontNameResolutionY); - XFormatFontName(&parsed, attributes, canon_font_name); - return 1; + unsigned int attributes; + XFontName parsed; + + if (!XParseFontName(font_name, &parsed, &attributes)) { + fprintf(stderr, "not a standard name: %s\n", font_name); + return 0; + } + + attributes &= ~(FontNamePixelSize | FontNameAverageWidth + | FontNamePointSize + | FontNameResolutionX | FontNameResolutionY); + XFormatFontName(&parsed, attributes, canon_font_name); + return 1; } static int FontNamesAmbiguous(const char *font_name, char **names, int count) { - char name1[2048], name2[2048]; - int i; - - if (count == 1) - return 0; - - for (i = 0; i < count; i++) { - if (!CanonicalizeFontName(names[i], i == 0 ? name1 : name2)) { - fprintf(stderr, "bad font name: %s\n", names[i]); - return 1; - } - if (i > 0 && strcmp(name1, name2) != 0) { - fprintf(stderr, "ambiguous font name: %s\n", font_name); - fprintf(stderr, " matches %s\n", names[0]); - fprintf(stderr, " and %s\n", names[i]); - return 1; - } - - } - return 0; + char name1[2048], name2[2048]; + int i; + + if (count == 1) + return 0; + + for (i = 0; i < count; i++) { + if (!CanonicalizeFontName(names[i], i == 0 ? name1 : name2)) { + fprintf(stderr, "bad font name: %s\n", names[i]); + return 1; + } + if (i > 0 && strcmp(name1, name2) != 0) { + fprintf(stderr, "ambiguous font name: %s\n", font_name); + fprintf(stderr, " matches %s\n", names[0]); + fprintf(stderr, " and %s\n", names[i]); + return 1; + } + } + return 0; } -static int -MapFont (char *font_name, const char *troff_name) +static int MapFont(char *font_name, const char *troff_name) { - XFontStruct *fi; - int count; - char **names; - FILE *out; - unsigned int c; - unsigned int attributes; - XFontName parsed; - int j, k; - DviCharNameMap *char_map; - char encoding[256]; - char *s; - int wid; - char name_string[2048]; - - if (!XParseFontName(font_name, &parsed, &attributes)) { - fprintf (stderr, "not a standard name: %s\n", font_name); - return 0; - } - - attributes &= ~(FontNamePixelSize|FontNameAverageWidth); - attributes |= FontNameResolutionX; - attributes |= FontNameResolutionY; - attributes |= FontNamePointSize; - parsed.ResolutionX = resolution; - parsed.ResolutionY = resolution; - parsed.PointSize = point_size*10; - XFormatFontName(&parsed, attributes, name_string); - - names = XListFonts (dpy, name_string, 100000, &count); - if (count < 1) { - fprintf (stderr, "bad font name: %s\n", font_name); - return 0; - } - - if (FontNamesAmbiguous(font_name, names, count)) - return 0; - - XParseFontName(names[0], &parsed, &attributes); - sprintf (encoding, "%s-%s", parsed.CharSetRegistry, - parsed.CharSetEncoding); - for (s = encoding; *s; s++) - if (isupper (*s)) - *s = tolower (*s); - char_map = DviFindMap (encoding); - if (!char_map) { - fprintf (stderr, "not a standard encoding: %s\n", encoding); - return 0; + XFontStruct *fi; + int count; + char **names; + FILE *out; + unsigned int c; + unsigned int attributes; + XFontName parsed; + int j, k; + DviCharNameMap *char_map; + char encoding[256]; + char *s; + int wid; + char name_string[2048]; + + if (!XParseFontName(font_name, &parsed, &attributes)) { + fprintf(stderr, "not a standard name: %s\n", font_name); + return 0; + } + + attributes &= ~(FontNamePixelSize | FontNameAverageWidth); + attributes |= FontNameResolutionX; + attributes |= FontNameResolutionY; + attributes |= FontNamePointSize; + parsed.ResolutionX = resolution; + parsed.ResolutionY = resolution; + parsed.PointSize = point_size * 10; + XFormatFontName(&parsed, attributes, name_string); + + names = XListFonts(dpy, name_string, 100000, &count); + if (count < 1) { + fprintf(stderr, "bad font name: %s\n", font_name); + return 0; + } + + if (FontNamesAmbiguous(font_name, names, count)) + return 0; + + XParseFontName(names[0], &parsed, &attributes); + sprintf(encoding, "%s-%s", parsed.CharSetRegistry, + parsed.CharSetEncoding); + for (s = encoding; *s; s++) + if (isupper(*s)) + *s = tolower(*s); + char_map = DviFindMap(encoding); + if (!char_map) { + fprintf(stderr, "not a standard encoding: %s\n", encoding); + return 0; + } + + fi = XLoadQueryFont(dpy, names[0]); + if (!fi) { + fprintf(stderr, "font does not exist: %s\n", names[0]); + return 0; + } + + printf("%s -> %s\n", names[0], troff_name); + + { /* Avoid race while opening file */ + int fd; + (void) unlink(troff_name); + fd = open(troff_name, O_WRONLY | O_CREAT | O_EXCL, 0600); + out = fdopen(fd, "w"); + } + + if (!out) { + perror(troff_name); + return 0; + } + fprintf(out, "name %s\n", troff_name); + if (!strcmp(char_map->encoding, "adobe-fontspecific")) + fprintf(out, "special\n"); + if (charExists(fi, ' ')) { + int w = charWidth(fi, ' '); + if (w > 0) + fprintf(out, "spacewidth %d\n", w); + } + fprintf(out, "charset\n"); + for (c = fi->min_char_or_byte2; c <= fi->max_char_or_byte2; c++) { + const char *name = DviCharName(char_map, c, 0); + if (charExists(fi, c)) { + wid = charWidth(fi, c); + + fprintf(out, "%s\t%d", name ? name : "---", wid); + int param[5]; + param[0] = charHeight(fi, c); + param[1] = charDepth(fi, c); + param[2] = 0; /* charRBearing (fi, c) - wid */ + param[3] = 0; /* charLBearing (fi, c) */ + param[4] = 0; /* XXX */ + for (j = 0; j < 5; j++) + if (param[j] < 0) + param[j] = 0; + for (j = 4; j >= 0; j--) + if (param[j] != 0) + break; + for (k = 0; k <= j; k++) + fprintf(out, ",%d", param[k]); + fprintf(out, "\t0\t0%o\n", c); + + if (name) { + for (k = 1; DviCharName(char_map, c, k); k++) { + fprintf(out, "%s\t\"\n", DviCharName(char_map, c, k)); } - - fi = XLoadQueryFont (dpy, names[0]); - if (!fi) { - fprintf (stderr, "font does not exist: %s\n", names[0]); - return 0; - } - - printf ("%s -> %s\n", names[0], troff_name); - - { /* Avoid race while opening file */ - int fd; - (void) unlink (troff_name); - fd = open (troff_name, O_WRONLY | O_CREAT | O_EXCL, 0600); - out = fdopen (fd, "w"); - } - - if (!out) { - perror (troff_name); - return 0; - } - fprintf (out, "name %s\n", troff_name); - if (!strcmp (char_map->encoding, "adobe-fontspecific")) - fprintf (out, "special\n"); - if (charExists (fi, ' ')) { - int w = charWidth (fi, ' '); - if (w > 0) - fprintf (out, "spacewidth %d\n", w); - } - fprintf (out, "charset\n"); - for (c = fi->min_char_or_byte2; c <= fi->max_char_or_byte2; c++) { - const char *name = DviCharName (char_map, c, 0); - if (charExists (fi, c) && (groff_flag || name)) { - - wid = charWidth (fi, c); - - fprintf (out, "%s\t%d", - name ? name : "---", - wid); - if (groff_flag) { - int param[5]; - param[0] = charHeight (fi, c); - param[1] = charDepth (fi, c); - param[2] = 0 /* charRBearing (fi, c) - wid */; - param[3] = 0 /* charLBearing (fi, c) */; - param[4] = 0; /* XXX */ - for (j = 0; j < 5; j++) - if (param[j] < 0) - param[j] = 0; - for (j = 4; j >= 0; j--) - if (param[j] != 0) - break; - for (k = 0; k <= j; k++) - fprintf (out, ",%d", param[k]); - } - fprintf (out, "\t0\t0%o\n", c); - - if (name) { - for (k = 1; DviCharName(char_map,c,k); k++) { - fprintf (out, "%s\t\"\n", - DviCharName (char_map,c,k)); - } - } - } - } - XUnloadFont (dpy, fi->fid); - fclose (out); - return 1; + } + } + } + XUnloadFont(dpy, fi->fid); + fclose(out); + return 1; } -static void -usage(const char *prog) +static void usage(FILE *stream) { - fprintf (stderr, - "usage: %s [-g] [-r resolution] [-s pointsize] FontMap\n", - prog); - exit (1); + fprintf(stream, + "usage: %s [-r resolution] [-s pointsize] FontMap\n", + program_name); } -int -main (int argc, char **argv) +int main(int argc, char **argv) { - char troff_name[1024]; - char font_name[1024]; - char line[1024]; - char *a, *b, c; - int position; - FILE *map; - int opt; - - while ((opt = getopt(argc, argv, "gr:s:")) != EOF) { - switch (opt) { - case 'g': - groff_flag = 1; - break; - case 'r': - sscanf(optarg, "%u", &resolution); - break; - case 's': - sscanf(optarg, "%u", &point_size); - break; - default: - usage(argv[0]); - } - } - if (argc - optind != 1) - usage(argv[0]); - - dpy = XOpenDisplay (0); - if (!dpy) { - fprintf (stderr, "Can't connect to the X server.\n"); - fprintf (stderr, "Make sure the DISPLAY environment variable is set correctly.\n"); - exit (1); - } - position = 1; - - map = fopen (argv[optind], "r"); - if (map == NULL) { - perror (argv[optind]); - exit (1); - } - - while (fgets (line, sizeof (line), map)) { - for (a=line,b=troff_name; *a; a++,b++) { - c = (*b = *a); - if (c == ' ' || c == '\t') - break; - } - *b = '\0'; - while (*a && (*a == ' ' || *a == '\t')) - ++a; - for (b=font_name; *a; a++,b++) - if ((*b = *a) == '\n') - break; - *b = '\0'; - if (!MapFont (font_name, troff_name)) - exit (1); - ++position; - } - exit (0); + char troff_name[1024]; + char font_name[1024]; + char line[1024]; + char *a, *b, c; + FILE *map; + int opt; + static const struct option long_options[] = { + { "help", no_argument, 0, CHAR_MAX + 1 }, + { "version", no_argument, 0, 'v' }, + { NULL, 0, 0, 0 } + }; + + program_name = argv[0]; + + while ((opt = getopt_long(argc, argv, "gr:s:v", long_options, + NULL)) != EOF) { + switch (opt) { + case 'g': + /* unused; just for compatibility */ + break; + case 'r': + sscanf(optarg, "%u", &resolution); + break; + case 's': + sscanf(optarg, "%u", &point_size); + break; + case 'v': + printf("xtotroff (groff) version %s\n", Version_string); + exit(0); + break; + case CHAR_MAX + 1: /* --help */ + usage(stdout); + exit(0); + break; + case '?': + usage(stderr); + exit(1); + break; + } + } + if (argc - optind != 1) { + usage(stderr); + exit(1); + } + + dpy = XOpenDisplay(0); + if (!dpy) { + fprintf(stderr, "Can't connect to the X server.\n"); + fprintf(stderr, + "Make sure the DISPLAY environment variable is set correctly.\n"); + exit(1); + } + + map = fopen(argv[optind], "r"); + if (map == NULL) { + perror(argv[optind]); + exit(1); + } + + while (fgets(line, sizeof(line), map)) { + for (a = line, b = troff_name; *a; a++, b++) { + c = (*b = *a); + if (c == ' ' || c == '\t') + break; + } + *b = '\0'; + while (*a && (*a == ' ' || *a == '\t')) + ++a; + for (b = font_name; *a; a++, b++) + if ((*b = *a) == '\n') + break; + *b = '\0'; + if (!MapFont(font_name, troff_name)) + exit(1); + } + exit(0); } - -/* -Local Variables: -c-indent-level: 8 -c-continued-statement-offset: 8 -c-brace-offset: -8 -c-argdecl-indent: 8 -c-label-offset: -8 -c-tab-always-indent: nil -End: -*/ diff --git a/src/utils/xtotroff/xtotroff.man b/src/utils/xtotroff/xtotroff.man new file mode 100644 index 00000000..d21bb5c1 --- /dev/null +++ b/src/utils/xtotroff/xtotroff.man @@ -0,0 +1,109 @@ +.ig +Copyright (C) 2004 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be included in +translations approved by the Free Software Foundation instead of in +the original English. +.. +. +. +.TH XTOTROFF @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +. +. +.SH NAME +xtotroff \- convert X font metrics into GNU troff font metrics +. +. +.SH SYNOPSIS +.B xtotroff +[ +.BI \-r \%resolution +] +[ +.BI \-s \%point-size +] +[ +.B \-v +] +.I FontMap +. +.PP +It is possible to have whitespace between a command line option and its +parameter. +. +. +.SH DESCRIPTION +.B xtotroff +takes a +.IR FontMap , +which maps +.B groff +fonts to X11 fonts, +creates GNU +.B troff +metric files for all fonts listed. +Each line in +.I FontMap +consists of GNU +.B troff +font name and an X font name (XLFD) pattern, separated by whitespace. +Example: +. +.PP +.in +2n +.nf +TB -adobe-times-bold-r-normal--*-*-*-*-p-*-iso8859-1 +.fi +.in +. +.PP +The wildcards in the patterns are filled with the arguments to the +.B \-r +and +.B \-s +switches. +If a font name is still ambiguous, +.B xtotroff +aborts. +. +. +.SH OPTIONS +.TP +.BI \-r resolution +Set the resolution for all font patterns in +.IR FontMap . +The value is used for both the horizontal and vertical resolution. +If not specified, a resolution of 75dpi is assumed. +. +.TP +.BI \-s point-size +Set the point size for all font patterns in +.IR FontMap . +If not specified, a size of 10pt is assumed. +. +.TP +.B \-v +Print the version number. +. +. +.SH BUGS +The only supported font encodings are `iso8859-1' and `adobe-fontspecific'. +. +. +.SH "SEE ALSO" +.BR gxditview (@MAN1EXT@) +. +.\" Local Variables: +.\" mode: nroff +.\" End: |