[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] grohtml related patches
From: |
Gaius Mulley |
Subject: |
[Groff] grohtml related patches |
Date: |
Fri, 18 Jan 2002 16:13:30 +0000 |
Hi Werner,
here are some small patches which allow grohtml users to determine the
number of anti aliasing bits used when generating png images.
Also I've set the t register to false and n register to 1 when we are
performing the raw html pass. Which finally transforms TEX into TeX in
pic.ms :-)
Gaius
--- groff-cvs/src/roff/troff/input.cc Tue Dec 25 08:14:35 2001
+++ groff-html/src/roff/troff/input.cc Fri Jan 18 11:46:16 2002
@@ -4810,11 +4810,17 @@
unsigned char c = tok.ch();
if (c == 't') {
tok.next();
- result = !nroff_mode;
+ if (is_html)
+ result = 0;
+ else
+ result = !nroff_mode;
}
else if (c == 'n') {
tok.next();
- result = nroff_mode;
+ if (is_html)
+ result = 1;
+ else
+ result = nroff_mode;
}
else if (c == 'v') {
tok.next();
--- groff-cvs/src/devices/grohtml/post-html.cc Sun Dec 30 14:48:04 2001
+++ groff-html/src/devices/grohtml/post-html.cc Fri Jan 18 15:22:21 2002
@@ -2832,12 +2832,18 @@
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- while ((c = getopt_long(argc, argv, "o:i:I:D:F:vbdhlrn", long_options, NULL))
+ while ((c = getopt_long(argc, argv, "a:g:o:i:I:D:F:vbdhlrn", long_options,
NULL))
!= EOF)
switch(c) {
case 'v':
printf("GNU post-grohtml (groff) version %s\n", Version_string);
exit(0);
+ break;
+ case 'a':
+ /* text antialiasing bits - handled by pre-html */
+ break;
+ case 'g':
+ /* graphic antialiasing bits - handled by pre-html */
break;
case 'b':
// set background color to white
--- groff-cvs/src/devices/grohtml/grohtml.man Sun Dec 30 14:48:04 2001
+++ groff-html/src/devices/grohtml/grohtml.man Fri Jan 18 15:44:04 2002
@@ -81,6 +81,36 @@
option.
.SH OPTIONS
.TP
+.B -a
+number of bits of antialiasing information to be used by \fItext\fP
+when generating png images. The default is 4 but legal values are 0, 1, 2 and
4.
+Note your version of
+.B gs
+needs to support the
+.B -dTextAlphaBits
+and
+.B -dGraphicAlphaBits
+options in order to exploit antialiasing.
+A value of 0 stops
+.B grohtml
+from issuing antialiasing commands to
+.B gs .
+.TP
+.B -g
+number of bits of antialiasing information to be used by \fIgraphics\fP
+when generating png images. The default is 4 but legal values are 0, 1, 2 and
4.
+Note your version of
+.B gs
+needs to support the
+.B -dTextAlphaBits
+and
+.B -dGraphicAlphaBits
+options in order to exploit antialiasing.
+A value of 0 stops
+.B grohtml
+from issuing antialiasing commands to
+.B gs .
+.TP
.B -b
initialize the background color to white.
.TP
--- groff-cvs/src/preproc/html/pre-html.cc Sun Dec 30 14:48:05 2001
+++ groff-html/src/preproc/html/pre-html.cc Fri Jan 18 16:02:55 2002
@@ -67,6 +67,8 @@
#define LETTER_OFFSET 50 // 50/72 of an inch
#define TRANSPARENT "-background white -transparent white"
+#define MIN_ALPHA_BITS 0
+#define MAX_ALPHA_BITS 4
#define PAGE_TEMPLATE_SHORT "pg"
#define PAGE_TEMPLATE_LONG "-page-"
@@ -89,21 +91,24 @@
typedef enum {CENTERED, LEFT, RIGHT, INLINE} IMAGE_ALIGNMENT;
-static int postscriptRes =-1; // postscript resolution, dots
per inch
-static int stdoutfd = 1; // output file descriptor -
normally 1 but might move
+static int postscriptRes =-1; // postscript resolution, dots
per inch
+static int stdoutfd = 1; // output file descriptor -
normally 1 but might move
// -1 means closed
-static int copyofstdoutfd =-1; // a copy of stdout, so we can
restore stdout when
+static int copyofstdoutfd =-1; // a copy of stdout, so we can
restore stdout when
// writing to post-html
-static char *psFileName = NULL; // name of postscript file
-static char *regionFileName = NULL; // name of file containing all
image regions
-static char *imagePageStem = NULL; // stem of all files
containing page images
-static char *image_device = "pnmraw";
-static int image_res = DEFAULT_IMAGE_RES;
-static int vertical_offset= 0;
-static char *image_template = NULL; // image template filename
-static int troff_arg = 0; // troff arg index
-static char *image_dir = NULL; // user specified image
directory
-static char *gsPaper = NULL; // the paper size that gs must
use
+static char *psFileName = NULL; // name of postscript file
+static char *regionFileName = NULL; // name of file containing all
image regions
+static char *imagePageStem = NULL; // stem of all files
containing page images
+static char *image_device = "pnmraw";
+static int image_res = DEFAULT_IMAGE_RES;
+static int vertical_offset = 0;
+static char *image_template = NULL; // image template filename
+static int troff_arg = 0; // troff arg index
+static char *image_dir = NULL; // user specified image
directory
+static char *gsPaper = NULL; // the paper size that gs must
use
+static int textAlphaBits = MAX_ALPHA_BITS;
+static int graphicAlphaBits = MAX_ALPHA_BITS;
+static char *antiAlias = NULL; // antialias arguments we pass
to gs.
#if defined(DEBUGGING)
static int debug = FALSE;
static char *troffFileName = NULL; // output of pre-html output
which is sent to troff -Tps
@@ -431,6 +436,23 @@
}
/*
+ * setupAntiAlias - sets up the antialias string, used when we call gs.
+ */
+
+static void setupAntiAlias (void)
+{
+ if (textAlphaBits == 0 && graphicAlphaBits == 0)
+ antiAlias = make_message(" ");
+ else if (textAlphaBits == 0)
+ antiAlias = make_message("-dGraphicsAlphaBits=%d ", graphicAlphaBits);
+ else if (graphicAlphaBits == 0)
+ antiAlias = make_message("-dTextAlphaBits=%d ", textAlphaBits);
+ else
+ antiAlias = make_message("-dTextAlphaBits=%d -dGraphicsAlphaBits=%d ",
+ textAlphaBits, graphicAlphaBits);
+}
+
+/*
* checkImageDir - checks to see whether the image directory is available.
*/
@@ -770,13 +792,13 @@
}
s = make_message("echo showpage | "
- "gs%s %s -q -dSAFER -sDEVICE=%s -r%d "
- "-dTextAlphaBits=4 -dGraphicsAlphaBits=4 "
+ "gs%s %s -q -dSAFER -sDEVICE=%s -r%d %s"
"-sOutputFile=%s/%%d %s -",
EXE_EXT,
gsPaper,
image_device,
image_res,
+ antiAlias,
imagePageStem,
psFileName);
if (s == NULL)
@@ -1250,12 +1272,26 @@
{ "version", no_argument, 0, 'v' },
{ NULL, 0, 0, 0 }
};
- while ((c = getopt_long(argc, argv, "+o:i:I:D:F:vbdhlrn", long_options,
NULL))
+ while ((c = getopt_long(argc, argv, "+a:g:o:i:I:D:F:vbdhlrn", long_options,
NULL))
!= EOF)
switch(c) {
case 'v':
printf("GNU pre-grohtml (groff) version %s\n", Version_string);
exit(0);
+ case 'a':
+ textAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)), MAX_ALPHA_BITS);
+ if (textAlphaBits == 3) {
+ error("cannot use 3 bits of antialiasing information");
+ exit(1);
+ }
+ break;
+ case 'g':
+ graphicAlphaBits = min(max(MIN_ALPHA_BITS, atoi(optarg)),
MAX_ALPHA_BITS);
+ if (graphicAlphaBits == 3) {
+ error("cannot use 3 bits of antialiasing information");
+ exit(1);
+ }
+ break;
case 'b':
// handled by post-grohtml (set background color to white)
break;
@@ -1367,6 +1403,7 @@
postscriptRes = get_resolution();
determine_vertical_offset();
i = scanArguments(argc, argv);
+ setupAntiAlias();
checkImageDir();
makeFileName();
while (i < argc) {