diff options
author | wlemb <wlemb> | 2002-09-23 09:52:25 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2002-09-23 09:52:25 +0000 |
commit | b5a23eba68b8860f6faba01b9920233f4cd4c43d (patch) | |
tree | 86b168a37f9a53a71396675fb00977240a2824ba | |
parent | 63b859ad972d8cae7c4b25edb749f3c67346d65a (diff) | |
download | groff-b5a23eba68b8860f6faba01b9920233f4cd4c43d.tar.gz |
* src/devices/grolbp/lbp.cc: Replace `300' with `font::res' where
appropriate.
(DEFAULT_LINEWIDTH_FACTOR): New macro.
(linewidth_factor): New global variable.
(lbp_printer::set_line_thickness): Fix case for size < 0, using
linewidth_factor.
(long_options): Add -w/--linewidth option.
(usage): Updated.
(main): Handle -w option to set linewidth_factor.
(lbp_printer::lbp_printer): Initialize req_linethickness, not
line_thickness.
* src/devices/grolbp/grolbp.man, NEWS, doc/webpage.ms: Updated.
Fixed a bug in the line thickness setting code.
* src/devices/grolbp/lbp.cc (lbp_printer::req_linethickness): New
variable.
(lbp_printer::set_line_thickness): Pass environment as second
parameter.
Implement it actually.
(lpb_printer::set_char, lbp_printer::draw): Use `req_linethickness'
and `set_line_thickness, depending on the current font size.
-rw-r--r-- | ChangeLog | 28 | ||||
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | doc/webpage.ms | 34 | ||||
-rw-r--r-- | src/devices/grolbp/grolbp.man | 10 | ||||
-rw-r--r-- | src/devices/grolbp/lbp.cc | 114 |
5 files changed, 141 insertions, 51 deletions
@@ -1,3 +1,31 @@ +2002-09-23 Werner LEMBERG <wl@gnu.org> + + * src/devices/grolbp/lbp.cc: Replace `300' with `font::res' where + appropriate. + (DEFAULT_LINEWIDTH_FACTOR): New macro. + (linewidth_factor): New global variable. + (lbp_printer::set_line_thickness): Fix case for size < 0, using + linewidth_factor. + (long_options): Add -w/--linewidth option. + (usage): Updated. + (main): Handle -w option to set linewidth_factor. + (lbp_printer::lbp_printer): Initialize req_linethickness, not + line_thickness. + + * src/devices/grolbp/grolbp.man, NEWS, doc/webpage.ms: Updated. + +2002-09-22 Paco Andrés Verdú <pandres@dragonet.es> + + Fixed a bug in the line thickness setting code. + + * src/devices/grolbp/lbp.cc (lbp_printer::req_linethickness): New + variable. + (lbp_printer::set_line_thickness): Pass environment as second + parameter. + Implement it actually. + (lpb_printer::set_char, lbp_printer::draw): Use `req_linethickness' + and `set_line_thickness, depending on the current font size. + 2002-09-21 Werner LEMBERG <wl@gnu.org> Some Debian patches. @@ -27,6 +27,12 @@ Tbl o Added global option `nospaces' to ignore leading and trailing spaces in data items. +Grolbp +------ + +o The option -w (--linewidth) has been added (similar to other device + drivers) to set the default line width. + Miscellaneous ------------- diff --git a/doc/webpage.ms b/doc/webpage.ms index f614c4c0..03c5787f 100644 --- a/doc/webpage.ms +++ b/doc/webpage.ms @@ -86,11 +86,11 @@ This is the GNU groff document formatting system. The version number is given in the file VERSION. Included in this release are implementations of troff, pic, eqn, tbl, refer, -the -man macros and the -ms macros, and drivers for PostScript, TeX dvi +the \-man macros and the \-ms macros, and drivers for PostScript, TeX dvi format, HP LaserJet 4 printers, HTML format (still alpha), and typewriter-like devices. -Also included is a modified version of the Berkeley -me macros, an enhanced -version of the X11 xditview previewer, and an implementation of the -mm +Also included is a modified version of the Berkeley \-me macros, an enhanced +version of the X11 xditview previewer, and an implementation of the \-mm macros contributed by .MTO jh@\:axis.se "J\[:o]rgen H\[:a]gg" . @@ -106,7 +106,7 @@ The file PROBLEMS describes various problems that have been encountered in compiling, installing, and running groff. For the moment, the documentation assumes that you are already familiar with -the Unix versions of troff, -man, -ms and the preprocessors. +the Unix versions of troff, \-man, \-ms and the preprocessors. The most recent released version of groff is always available by anonymous ftp from ftp.gnu.org in the directory pub/\:gnu/\:groff. @@ -238,6 +238,15 @@ items. .ULE . .SH 2 +grolbp + +.ULS +.LI +The option \-w (\-\-linewidth) has been added (similar to other device +drivers) to set the default line width. +.ULE +. +.SH 2 Miscellaneous .ULS @@ -329,8 +338,8 @@ Two new glyph symbols are available: `eu' is the official Euro symbol; `Eu' is a font-specific glyph variant. .LI -The new glyph symbols `t+-', `tdi', and `tmu' are textual variants of -`+-', `di', and `mu', respectively. +The new glyph symbols `t+\-', `tdi', and `tmu' are textual variants of +`+\-', `di', and `mu', respectively. .LI Latin-1 character 181 (PS name `mu', Unicode name U+00B5 MICRO SIGN) has @@ -405,7 +414,7 @@ them. .LI The syntax of the `substring' request has been changed: The first character in a string now has index\~0, the last character -has index\~-1. +has index\~\-1. Note that this is an incompatible change. .LI @@ -615,17 +624,16 @@ The new macro `HX' determines the cut-off point for automatic link generation to headings. .LI -The image position parameter names in `IMG' have been changed to `-L', -`-R', and `-C'. +The image position parameter names in `IMG' have been changed to `\-L', +`\-R', and `\-C'. .LI New macro `PIMG' for inclusion of a PNG image (it will automatically -convert it into an EPS file if not -Thtml is used). +convert it into an EPS file if not \-Thtml is used). .LI New macro `MPIMG' for putting a PNG image into the left or right margin -(it will automatically convert it into an EPS file if not --Thtml is used). +(it will automatically convert it into an EPS file if not \-Thtml is used). .LI New macros `HnS', `HnE' to start and end a header line block. @@ -774,7 +782,7 @@ Two font families are now available: `T' and `H'. .LI EC and TC fonts have been integrated. -Use `-mec' (calling the file ec.tmac) to switch to them. +Use `\-mec' (calling the file ec.tmac) to switch to them. Those fonts give a much better coverage of the symbols defined by groff than the CM fonts. diff --git a/src/devices/grolbp/grolbp.man b/src/devices/grolbp/grolbp.man index ddcb2cad..6685c4f9 100644 --- a/src/devices/grolbp/grolbp.man +++ b/src/devices/grolbp/grolbp.man @@ -61,6 +61,8 @@ grolbp \- groff driver for Canon CAPSL printers (LBP-4 and LBP-8 series laser pr .OP \-\-papersize= paper_size .OP \-o orientation .OP \-\-orientation= orientation +.OP \-w width +.OP \-\-linewidth= width .OP \-F dir .OP \-\-fontdir= dir .OP \-h @@ -116,6 +118,14 @@ Print the document with .I orientation orientation, which must be `portrait' or `landscape'. .TP +.BI \-w width +.TQ +.BI \-\-linewidth= width +Set the default line thickness to +.I width +thousandths of an em. +If this option isn't specified, the line thickness defaults to 0.04\~em. +.TP .B \-v .TQ .B \-\-version diff --git a/src/devices/grolbp/lbp.cc b/src/devices/grolbp/lbp.cc index eddd5ce2..76db32a4 100644 --- a/src/devices/grolbp/lbp.cc +++ b/src/devices/grolbp/lbp.cc @@ -42,6 +42,9 @@ static double user_paperlength = 0; // Custom Paper size static double user_paperwidth = 0; static int ncopies = 1; // Number of copies +#define DEFAULT_LINEWIDTH_FACTOR 40 // 0.04em +static int linewidth_factor = DEFAULT_LINEWIDTH_FACTOR; + static int set_papersize(const char *paperformat); class lbp_font : public font { @@ -67,7 +70,7 @@ public: font *make_font(const char *); void end_of_line(); private: - void set_line_thickness(int size, int dot = 0); + void set_line_thickness(int size,const environment *env); void vdmstart(); void vdmflush(); // the name vdmend was already used in lbp.h void setfillmode(int mode); @@ -82,8 +85,9 @@ private: int cur_size; unsigned short cur_symbol_set; int line_thickness; + int req_linethickness; // requested line thickness int papersize; - int paperlength; // custum paper size + int paperlength; // custom paper size int paperwidth; }; @@ -161,7 +165,7 @@ lbp_printer::lbp_printer(int ps, double pw, double pl) cur_font(0), cur_size(0), cur_symbol_set(0), - line_thickness(-1) + req_linethickness(-1) { #ifdef SET_BINARY SET_BINARY(fileno(stdout)); @@ -278,21 +282,24 @@ void lbp_printer::set_char(int index, font *f, const environment *env, if (psf->is_scalable) { // Scalable font selection is different from bitmaped lbpprintf("\033Pz%s.IBML\033\\\033[%d C", psf->lbpname, - (int)((env->size * 300) / 72)); + (int)((env->size * font::res) / 72)); } else // bitmapped font lbpprintf("\033Pz%s.IBML\033\\\n", font_name(psf, env->size)); lbpputs("\033)' 1"); // Select IBML and IBMR1 symbol set - cur_size = env->size; cur_font = psf; cur_symbol_set = 0; + // Update the line thickness if needed + if ((req_linethickness < 0 ) && (env->size != cur_size)) + set_line_thickness(req_linethickness,env); + cur_size = env->size; } if (symbol_set != cur_symbol_set) { if (cur_symbol_set == 3) // if current symbol set is Symbol we must restore the font lbpprintf("\033Pz%s.IBML\033\\\033[%d C", cur_font->lbpname, - (int)((env->size * 300) / 72)); + (int)((env->size * font::res) / 72)); switch (symbol_set) { case 0: lbpputs("\033('$2\033)' 1"); // Select IBML and IBMR1 symbol sets @@ -305,7 +312,7 @@ void lbp_printer::set_char(int index, font *f, const environment *env, break; case 3: lbpprintf("\033PzSymbol.SYML\033\\\033[%d C", - (int)((env->size * 300) / 72)); + (int)((env->size * font::res) / 72)); lbpputs("\033(\"!!0\033)\"!!1"); // Select symbol font break; case 4: @@ -318,8 +325,11 @@ void lbp_printer::set_char(int index, font *f, const environment *env, if (!cur_font->is_scalable) lbpprintf("\033Pz%s.IBML\033\\\n", font_name(cur_font, env->size)); else - lbpprintf("\033[%d C", (int)((env->size * 300) / 72)); + lbpprintf("\033[%d C", (int)((env->size * font::res) / 72)); cur_size = env->size; + // Update the line thickness if needed + if (req_linethickness < 0 ) + set_line_thickness(req_linethickness,env); } if ((env->hpos != cur_hpos) || (env->vpos != cur_vpos)) { // lbpmoveabs(env->hpos - ((5 * 300) / 16), env->vpos); @@ -394,8 +404,35 @@ inline void lbp_printer::polygon(int hpos, int vpos, int np, int *p) vdmpolygon((np /2) + 1, points); } +inline void lbp_printer::set_line_thickness(int size,const environment *env) +{ + if (size == 0) + line_thickness = 1; + else { + if (size < 0) + // line_thickness = + // (env->size * (font::res/72)) * (linewidth_factor/1000) + // we ought to check for overflow + line_thickness = + env->size * linewidth_factor * font::res / 72000; + else // size > 0 + line_thickness = size; + } // else from if (size == 0) + if (line_thickness < 1) + line_thickness = 1; + if (vdminited()) + vdmlinewidth(line_thickness); + req_linethickness = size; // an size requested + /* fprintf(stderr, "thickness: %d == %d, size %d, %d \n", + size, line_thickness, env->size,req_linethickness); */ + return; +}; // lbp_printer::set_line_thickness + void lbp_printer::draw(int code, int *p, int np, const environment *env) { + if ((req_linethickness < 0 ) && (env->size != cur_size)) + set_line_thickness(req_linethickness,env); + switch (code) { case 't': if (np == 0) @@ -404,23 +441,9 @@ void lbp_printer::draw(int code, int *p, int np, const environment *env) if (np != 1 && np != 2) { error("0 or 1 argument required for thickness"); break; - } - if (p[0] == 0) - line_thickness = 1; - if (p[0] < 0) - // Default = 1 point - line_thickness = (int)(env->size * 30 / 72); - line_thickness = (int)((abs(p[0]) * env->size) / 10); - if ((line_thickness > 16) && (!vdminited())) { - /* for greater thickness we must use VDM */ - vdmstart(); - // vdmlinewidth(line_thickness); // already done in vdmstart() - } - if (vdminited()) - vdmlinewidth(line_thickness); - // fprintf(stderr, "\nthickness: %d == %d, size %d\n", - // p[0], line_thickness, env->size); - } + }; + set_line_thickness(p[0],env); + }; break; case 'l': // Line if (np != 2) { @@ -430,9 +453,9 @@ void lbp_printer::draw(int code, int *p, int np, const environment *env) if (!vdminited()) vdmstart(); vdmline(env->hpos, env->vpos, p[0], p[1]); - // fprintf(stderr, "\nline: %d,%d - %d,%d thickness %d == %d\n", - // env->hpos - 64,env->vpos -64, env->hpos - 64 + p[0], - // env->vpos -64 + p[1], env->size, line_thickness); +/* fprintf(stderr, "\nline: %d,%d - %d,%d thickness %d == %d\n", + env->hpos - 64,env->vpos -64, env->hpos - 64 + p[0], + env->vpos -64 + p[1], env->size, line_thickness);*/ break; case 'R': // Rule if (np != 2) { @@ -608,6 +631,7 @@ static struct option long_options[] = { { "copies", required_argument, NULL, 'c' }, { "landscape", no_argument, NULL, 'l' }, { "papersize", required_argument, NULL, 'p' }, + { "linewidth", required_argument, NULL, 'w' }, { "fontdir", required_argument, NULL, 'F' }, { "help", no_argument, NULL, 'h' }, { NULL, 0, 0, 0 } @@ -616,15 +640,17 @@ static struct option long_options[] = { static void usage(FILE *stream) { fprintf(stream, - "usage: %s [-lvh] [-c n] [-p paper_size] [-F dir] [-o or] " - " [files ...]\n" - " -o --orientation=[portrait|landscape]\n" - " -v --version\n" - " -c --copies=numcopies\n" - " -l --landscape\n" - " -p --papersize=paper_size\n" - " -F --fontdir=dir\n" - " -h --help\n", + "usage: %s [-lvh] [-c n] [-p paper_size] [-F dir] [-o or]\n" + " [-w width] [files ...]\n" + "\n" + " -o --orientation=[portrait|landscape]\n" + " -v --version\n" + " -c --copies=numcopies\n" + " -l --landscape\n" + " -p --papersize=paper_size\n" + " -w --linewidth=width\n" + " -F --fontdir=dir\n" + " -h --help\n", program_name); } @@ -637,7 +663,7 @@ int main(int argc, char **argv) int c = 0; int option_index = 0; while (c >= 0) { - c = getopt_long (argc, argv, "F:p:lvo:c:h", + c = getopt_long (argc, argv, "F:p:lvo:c:hw:", long_options, &option_index); switch (c) { case 'F': @@ -682,6 +708,18 @@ int main(int argc, char **argv) ncopies = unsigned(n); break; } + case 'w': + { + char *ptr; + long n = strtol(optarg, &ptr, 10); + if (n == 0 && ptr == optarg) + error("argument for -w must be a non-negative integer"); + else if (n < 0 || n > INT_MAX) + error("out of range argument for -w"); + else + linewidth_factor = int(n); + break; + } case 'h': usage(stdout); exit(0); |