From c495a86e1cb9d8673ffc6de70f51f98c82ffb3e3 Mon Sep 17 00:00:00 2001 From: Steffen Nurpmeso Date: Fri, 19 Sep 2014 22:53:46 +0200 Subject: [PATCH] Adapt src/dev-dvi (src/devices/grodvi) --- src/devices/grodvi/grodvi.man => man/dev-dvi.1.in | 86 +++++++++--------- src/dev-dvi/dvi-config.h.in | 22 +++++ src/{devices/grodvi => dev-dvi}/dvi.cpp | 105 +++++++++++----------- 3 files changed, 114 insertions(+), 99 deletions(-) rename src/devices/grodvi/grodvi.man => man/dev-dvi.1.in (85%) create mode 100644 src/dev-dvi/dvi-config.h.in rename src/{devices/grodvi => dev-dvi}/dvi.cpp (92%) diff --git a/src/devices/grodvi/grodvi.man b/man/dev-dvi.1.in similarity index 85% rename from src/devices/grodvi/grodvi.man rename to man/dev-dvi.1.in index 448a9a08..912dbc66 100644 --- a/src/devices/grodvi/grodvi.man +++ b/man/dev-dvi.1.in @@ -1,5 +1,9 @@ .ig -Copyright (C) 1989-2000, 2001, 2002, 2003, 2004, 2006 +@ @L_D_DVI@.1 + +Copyright (c) 2014 Steffen (Daode) Nurpmeso . + +Copyright (C) 1989 - 2004, 2006 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of @@ -18,7 +22,7 @@ translations approved by the Free Software Foundation instead of in the original English. .. . -.do nr grodvi_C \n[.C] +.do nr devdvi_C \n[.C] .cp 0 . .ie t .ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X @@ -42,13 +46,13 @@ the original English. .. . . -.TH GRODVI @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@" +.TH @U_D_DVI@ @MAN1EXT@ "@MDATE@" "@T_ROFF@ v@VERSION@" .SH NAME -grodvi \- convert groff output to TeX dvi format +@L_D_DVI@ \- convert @T_ROFF@ output to TeX dvi format . . .SH SYNOPSIS -.B grodvi +.B @L_D_DVI@ [ .B \-dlv ] [ @@ -66,23 +70,21 @@ parameter. . . .SH DESCRIPTION -.B grodvi +.B @L_D_DVI@ is a driver for -.B groff +.B @T_ROFF@ that produces \*(tx dvi format. . Normally it should be run by -.BR groff\ \-Tdvi . +.BR @L_ROFF@\ \-Tdvi . . This will run -.BR @g@troff\ \-Tdvi ; +.BR @L_TROFF@\ \-Tdvi ; it will also input the macros in .BR @MACRODIR@/dvi.tmac . . .LP -The dvi file generated by -.B grodvi -can be printed by any correctly-written dvi driver. +The generated dvi file can be printed by any correctly-written dvi driver. . The troff drawing primitives are implemented using the tpic version\~2 specials. @@ -109,7 +111,7 @@ driver that does not support the tpic specials unlike the other commands. . .LP -The groff command +The @T_ROFF@ command .BI \[rs]X' anything ' is translated into the same command in the dvi file as would be produced by @@ -128,14 +130,12 @@ automatically, providing the macro. . Please check -.BR groff_tmac (@MAN5EXT@) +.BR @L_ROFF@_tmac (@MAN5EXT@) for a detailed description. . .LP -Font files for -.B grodvi -can be created from tfm files using -.BR tfmtodit (@MAN1EXT@). +Font files can be created from tfm files using +.BR @L_TFMTODIT@ (@MAN1EXT@). . The font description file should contain the following additional commands: @@ -159,7 +159,7 @@ The designsize in the tfm file is . .LP These are automatically generated by -.B tfmtodit. +.B @L_TFMTODIT@. . .LP The default color for @@ -186,7 +186,7 @@ By design, the DVI format doesn't care about physical dimensions of the output medium. . Instead, -.B grodvi +.B @L_D_DVI@ emits the equivalent to \*(tx's .BI \[rs]special{papersize= width , length } on the first page; @@ -233,7 +233,7 @@ commands in the file; it accepts the same arguments as the .B papersize command (see -.BR groff_font (@MAN5EXT@) +.BR @L_ROFF@_font (@MAN5EXT@) for details). . .TP @@ -370,7 +370,7 @@ Using the option provides the EC and TC fonts. . The design of the EC family is very similar to that of the CM fonts; -additionally, they give a much better coverage of groff symbols. +additionally, they give a much better coverage of @T_ROFF@ symbols. . Note that .B ec.tmac @@ -381,32 +381,32 @@ hcode values. .SH ENVIRONMENT .TP .SM -.B GROFF_FONT_PATH +.B @U_ROFF@_FONT_PATH A list of directories in which to search for the .BI dev name directory in addition to the default ones. . See -.BR @g@troff (@MAN1EXT@) +.BR \%@L_TROFF@ (@MAN1EXT@) and -.BR \%groff_font (@MAN5EXT@) +.BR \%@L_ROFF@_font (@MAN5EXT@) for more details. . . .SH FILES .TP -.B @FONTDIR@/devdvi/DESC +.B @FONTDIR@/dvi/DESC Device description file. . .TP -.BI @FONTDIR@/devdvi/ F +.BI @FONTDIR@/dvi/ F Font description file for font .IR F . . .TP .B @MACRODIR@/dvi.tmac Macros for use with -.BR grodvi . +.BR @L_D_DVI@ . . .TP .B @MACRODIR@/ec.tmac @@ -415,14 +415,13 @@ Macros to switch to EC fonts. . .SH BUGS Dvi files produced by -.B grodvi +.B @L_D_DVI@ use a different resolution (57816 units per inch) to those produced by \*(tx. . Incorrectly written drivers which assume the resolution used by \*(tx, -rather than using the resolution specified in the dvi file will not -work with -.BR grodvi . +rather than using the resolution specified in the dvi file, will not +work. . .LP When using the @@ -435,16 +434,13 @@ and widths of rules be rounded. . . .SH "SEE ALSO" -.BR tfmtodit (@MAN1EXT@), -.BR groff (@MAN1EXT@), -.BR @g@troff (@MAN1EXT@), -.BR groff_out (@MAN5EXT@), -.BR groff_font (@MAN5EXT@), -.BR groff_char (@MAN7EXT@), -.BR groff_tmac (@MAN5EXT@) -. -.cp \n[grodvi_C] -. -.\" Local Variables: -.\" mode: nroff -.\" End: +.BR @L_TFMTODIT@ (@MAN1EXT@), +.BR @L_ROFF@ (@MAN1EXT@), +.BR @L_TROFF@ (@MAN1EXT@), +.BR @L_ROFF@_out (@MAN5EXT@), +.BR @L_ROFF@_font (@MAN5EXT@), +.BR @L_ROFF@_tmac (@MAN5EXT@), +.BR @L_ROFF@_char (@MAN7EXT@) +. +.cp \n[devdvi_C] +.\" s-ts-mode diff --git a/src/dev-dvi/dvi-config.h.in b/src/dev-dvi/dvi-config.h.in new file mode 100644 index 00000000..aef91d83 --- /dev/null +++ b/src/dev-dvi/dvi-config.h.in @@ -0,0 +1,22 @@ +/*@ Configurable stuff */ +#ifndef _DVI_CONFIG_H +#define _DVI_CONFIG_H + +#define DEFAULT_LINEWIDTH 40 + +// These values were chosen because: +// (MULTIPLIER*SIZESCALE)/(RES*UNITWIDTH) == 1/(2^20 * 72.27) +// and 57816 is an exact multiple of both 72.27*SIZESCALE and 72. +// +// The width in the roff font file is the product of MULTIPLIER and the width +// in the tfm file. +#define RES 57816 +#define RES_7227 (RES/7227) +#define UNITWIDTH 131072 +#define SIZESCALE 100 +#define MULTIPLIER 1 + +#define FONTS_MAX 256 + +#endif // _DVI_CONFIG_H +// s-it2-mode diff --git a/src/devices/grodvi/dvi.cpp b/src/dev-dvi/dvi.cpp similarity index 92% rename from src/devices/grodvi/dvi.cpp rename to src/dev-dvi/dvi.cpp index d6b68d1a..fbefb711 100644 --- a/src/devices/grodvi/dvi.cpp +++ b/src/dev-dvi/dvi.cpp @@ -1,32 +1,33 @@ -// -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004, 2006, - 2007 - 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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ +/*@ DVI output device. + * + * Copyright (c) 2014 Steffen (Daode) Nurpmeso . + * + * Copyright (C) 1989 - 1992, 2000 - 2004, 2006 - 2007 + * Free Software Foundation, Inc. + * Written by James Clark (jjc@jclark.com) + * + * 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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "dvi-config.h" #include "driver.h" #include "nonposix.h" #include "paper.h" -extern "C" const char *Version_string; - -#define DEFAULT_LINEWIDTH 40 static int linewidth = DEFAULT_LINEWIDTH; static int draw_flag = 1; @@ -35,29 +36,19 @@ static int landscape_flag = 0; static double user_paper_length = 0; static double user_paper_width = 0; -/* These values were chosen because: - -(MULTIPLIER*SIZESCALE)/(RES*UNITWIDTH) == 1/(2^20 * 72.27) - -and 57816 is an exact multiple of both 72.27*SIZESCALE and 72. - -The width in the groff font file is the product of MULTIPLIER and the -width in the tfm file. */ - -#define RES 57816 -#define RES_7227 (RES/7227) -#define UNITWIDTH 131072 -#define SIZESCALE 100 -#define MULTIPLIER 1 - -class dvi_font : public font { +class dvi_font +: public font +{ dvi_font(const char *); + public: int checksum; int design_size; + ~dvi_font(); void handle_unknown_font_command(const char *command, const char *arg, const char *filename, int lineno); + static dvi_font *load_dvi_font(const char *); }; @@ -105,15 +96,17 @@ void dvi_font::handle_unknown_font_command(const char *command, } } -#define FONTS_MAX 256 - -struct output_font { +class output_font +{ +public: dvi_font *f; int point_size; output_font() : f(0) { } }; -class dvi_printer : public printer { +class dvi_printer +: public printer +{ FILE *fp; int max_drift; int byte_count; @@ -132,12 +125,14 @@ class dvi_printer : public printer { int pushed_h; int pushed_v; int have_pushed; + void preamble(); void postamble(); void define_font(int); void set_font(int); void possibly_begin_line(); void set_color(color *); + protected: enum { id_byte = 2, @@ -170,6 +165,7 @@ protected: void out_signed(unsigned char, int); void out_unsigned(unsigned char, int); void do_special(const char *); + public: dvi_printer(); ~dvi_printer(); @@ -182,11 +178,13 @@ public: void draw(int, int *, int, const environment *); }; - -class draw_dvi_printer : public dvi_printer { +class draw_dvi_printer +: public dvi_printer +{ int output_pen_size; void set_line_thickness(const environment *); void fill_next(const environment *); + public: draw_dvi_printer(); ~draw_dvi_printer(); @@ -217,7 +215,6 @@ dvi_printer::~dvi_printer() postamble(); } - draw_dvi_printer::draw_dvi_printer() : output_pen_size(-1) { @@ -227,7 +224,6 @@ draw_dvi_printer::~draw_dvi_printer() { } - void dvi_printer::out1(int n) { byte_count += 1; @@ -265,7 +261,6 @@ void dvi_printer::out_string(const char *s) out1(*s++); } - void dvi_printer::end_of_line() { if (pushed) { @@ -493,8 +488,8 @@ void dvi_printer::postamble() out1(id_byte); for (i = 0; i < 4 || byte_count % 4 != 0; i++) out1(filler); -} - +} + void dvi_printer::begin_page(int i) { page_count++; @@ -910,7 +905,7 @@ static void usage(FILE *stream); int main(int argc, char **argv) { - setlocale(LC_NUMERIC, "C"); + setlocale(LC_NUMERIC, "C"); // FIXME this is the default, noone else sets it!? program_name = argv[0]; static char stderr_buf[BUFSIZ]; setbuf(stderr, stderr_buf); @@ -942,7 +937,7 @@ int main(int argc, char **argv) break; case 'v': { - printf("GNU grodvi (groff) version %s\n", Version_string); + puts(L_D_DVI " (" T_ROFF ") v" VERSION); exit(0); break; } @@ -976,6 +971,8 @@ int main(int argc, char **argv) static void usage(FILE *stream) { - fprintf(stream, "usage: %s [-dv] [-F dir] [-w n] [files ...]\n", + fprintf(stream, "Synopsis: %s [-dv] [-F dir] [-w n] [files ...]\n", program_name); } + +// s-it2-mode -- 2.11.4.GIT