[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] better fix for bad tables (ignore previous)
From: |
Gaius Mulley |
Subject: |
Re: [Groff] better fix for bad tables (ignore previous) |
Date: |
Fri, 21 Dec 2001 12:43:03 +0000 |
oops a better solution is here, (sorry about the previous patch)
This time if the user alters the pagelength in devps/DESC grohtml
will scale the vertical offset appropriately,
Gaius
*** groff-cvs/src/preproc/html/pre-html.cc Mon Dec 10 22:00:54 2001
--- groff-html/src/preproc/html/pre-html.cc Fri Dec 21 12:32:37 2001
***************
*** 58,71 ****
#include "html-strings.h"
#define DEFAULT_IMAGE_RES 80 // 80 pixels per inch resolution
! #ifdef PAGEA4
! # define DEFAULT_VERTICAL_OFFSET 0 // DEFAULT_VERTICAL_OFFSET/72 of an
inch
! #else
! # define DEFAULT_VERTICAL_OFFSET 50 // DEFAULT_VERTICAL_OFFSET/72 of an
inch
! #endif
#define IMAGE_BOARDER_PIXELS 2
#define MAX_WIDTH 8 // inches
#define INLINE_LEADER_CHAR '\\'
#define TRANSPARENT "-background white -transparent white"
--- 58,71 ----
#include "html-strings.h"
#define DEFAULT_IMAGE_RES 80 // 80 pixels per inch resolution
! #define DEFAULT_VERTICAL_OFFSET 0 // DEFAULT_VERTICAL_OFFSET/72 of an
inch
#define IMAGE_BOARDER_PIXELS 2
#define MAX_WIDTH 8 // inches
#define INLINE_LEADER_CHAR '\\'
+ #define A4_LENGTH 841890 // taken from devps/Makefile.sub
+ #define LETTER_LENGTH 792000 // taken from devps/Makefile.sub
+ #define A4_OFFSET 0
+ #define LETTER_OFFSET 50 // 50/72 of an inch
#define TRANSPARENT "-background white -transparent white"
***************
*** 100,109 ****
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= DEFAULT_VERTICAL_OFFSET;
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
#if defined(DEBUGGING)
static int debug = FALSE;
static char *troffFileName = NULL; // output of pre-html output
which is sent to troff -Tps
--- 100,110 ----
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
#if defined(DEBUGGING)
static int debug = FALSE;
static char *troffFileName = NULL; // output of pre-html output
which is sent to troff -Tps
***************
*** 139,155 ****
* get_resolution - returns the postscript resolution from devps/DESC
*/
! static int get_resolution (void)
{
char *pathp;
FILE *f;
! unsigned long int res;
int n;
int c;
f = font_path.open_file("devps/DESC", &pathp);
if (f == 0) sys_fatal("fopen");
while (1) {
! n = fscanf(f, " res %lu", &res);
if (n < 0) sys_fatal("EOF");
if (n >= 1) {
fclose(f);
--- 140,156 ----
* get_resolution - returns the postscript resolution from devps/DESC
*/
! static unsigned int get_resolution (void)
{
char *pathp;
FILE *f;
! unsigned int res;
int n;
int c;
f = font_path.open_file("devps/DESC", &pathp);
if (f == 0) sys_fatal("fopen");
while (1) {
! n = fscanf(f, " res %u", &res);
if (n < 0) sys_fatal("EOF");
if (n >= 1) {
fclose(f);
***************
*** 161,166 ****
--- 162,203 ----
}
/*
+ * get_papersize - returns an integer determining the paper length from
devps/DESC
+ */
+
+ static int get_papersize (void)
+ {
+ char *pathp;
+ FILE *f;
+ int res;
+ int n;
+ int c;
+ f = font_path.open_file("devps/DESC", &pathp);
+ if (f == 0) sys_fatal("fopen");
+ while (1) {
+ n = fscanf(f, " paperlength %d", &res);
+ if (n < 0) sys_fatal("EOF");
+ if (n >= 1) {
+ fclose(f);
+ return res;
+ }
+ while (( c = getc(f) ) != '\n')
+ if (c == EOF) sys_fatal("EOF");
+ }
+ }
+
+ /*
+ * determine_vertical_offset - works out the default vertical offset from
+ * the page length
+ */
+
+ static void determine_vertical_offset (void)
+ {
+ vertical_offset = ((A4_LENGTH-get_papersize())*72)/postscriptRes;
+ gsPaper = "-sPAPERSIZE=a4";
+ }
+
+ /*
* html_system - a wrapper for system()
*/
***************
*** 734,742 ****
}
s = make_message("echo showpage | "
! "gs%s -q -dSAFER -sDEVICE=%s -r%d "
"-sOutputFile=%s/%%d %s -",
EXE_EXT,
image_device,
image_res,
imagePageStem,
--- 771,780 ----
}
s = make_message("echo showpage | "
! "gs%s %s -q -dSAFER -sDEVICE=%s -r%d "
"-sOutputFile=%s/%%d %s -",
EXE_EXT,
+ gsPaper,
image_device,
image_res,
imagePageStem,
***************
*** 1233,1238 ****
--- 1271,1277 ----
break;
case 'o':
vertical_offset = atoi(optarg);
+ gsPaper = ""; // do not specify the paper size now
break;
case 'd':
#if defined(DEBUGGING)
***************
*** 1322,1329 ****
int found=0;
int ok=1;
- i = scanArguments(argc, argv);
postscriptRes = get_resolution();
checkImageDir();
makeFileName();
while (i < argc) {
--- 1361,1369 ----
int found=0;
int ok=1;
postscriptRes = get_resolution();
+ determine_vertical_offset();
+ i = scanArguments(argc, argv);
checkImageDir();
makeFileName();
while (i < argc) {
- Re: [Groff] Bad table images with groff -t -man -Thtml xxx.1, (continued)