groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] improved html.cc


From: Gaius Mulley
Subject: [Groff] improved html.cc
Date: Wed, 6 Oct 99 15:56 BST

Hi Werner,
         Here are some more bug fixes to the html driver.
I've been working though your email, still no -P-a switch,
definitely the next to do. But I thought I'd better fix
existing code before adding new code..

from the ChangeLog:

   introduced command line options -r to determine the resolution
   of generated images, -I to determine the format of images generated.

   Fixed many bugs to do with superscripts, subscripts, indentation,
   font changes and extraneous spaces.

   Fixed bug in determining the range of polygons and splines.

   Updated the manual page to reflect the new options.

   The default image type is png format, however this will only work
   if you have a gs with a png output device. If you don't have a gs
   with this ability you can either reconfigure html to generate gif
   images by default (alter a #define in html.cc). Or alternatively
   you can use the -Igif option.

What are your thoughts about using png format by default - is it likely
that we can assume people will be using gs with png devices present?
I guess the better solution would be to include this in the auto configuration?

I've tested out the patch from a copy of the groff from the repository this
morning and it seems to work for my test data, I will continue to test 
vigorously
though

cheers Gaius

-------------- cut here -------------- cut here -------------- cut here ---
diff -r -c groff/tmac/tmac.arkup groff.html/tmac/tmac.arkup
*** groff/tmac/tmac.arkup       Sun Sep 26 09:37:11 1999
--- groff.html/tmac/tmac.arkup  Mon Oct  4 11:02:31 1999
***************
*** 4,9 ****
--- 4,11 ----
  .\"  please can someone with more skill at creating macros improve on this
  .\"  many thanks - Gaius
  .\"
+ .\"  suggestion: maybe when run with non -Thtml all the urls should appear as
+ .\"  references.
  .\"
  .\" some simple html additions to any macro set
  .\"
***************
*** 14,19 ****
--- 16,31 ----
  .if '\*(.T'html' \X^index:\\$*^
  ..
  .\"
+ .\"  BODYCOLOR - $1 is foreground color
+ .\"              $2 is background color
+ .\"              $3 is the color of an active hypertext link
+ .\"              $4 is the color of a hypertext link not yet visited
+ .\"              $5 is the color of a visited hypertext link
+ .\"
+ .de BODYCOLOR
+ .   HTML "<body text=\"$1\" bgcolor=\"$2\" link=\"$3\" alink=\"$4\" 
vlink=\"$5\">"
+ ..
+ .\"
  .\"  URL - $1 is the classical underlined blue text
  .\"        $2 is the url
  .\"
***************
*** 22,28 ****
  .        HTML <a href="\\$2">\\$1</a>
  .   \}
  .   el \{\
! \fI\\$1\s-2\f[CR] <url: \\$2>\fP\s+2
  .   \}
  ..
  .\"
--- 34,40 ----
  .        HTML <a href="\\$2">\\$1</a>
  .   \}
  .   el \{\
! \\$1 (<url: \\$2>)
  .   \}
  ..
  .\"
***************
*** 36,42 ****
  .\"
  .\"                   .LINK "The GNU FSF" "" "www.gnu.org"
  .\"
! .\"                    deprecated - use the WWW macro instead
  .\"         
  .\"
  .de LINK
--- 48,54 ----
  .\"
  .\"                   .LINK "The GNU FSF" "" "www.gnu.org"
  .\"
! .\"                    deprecated - use the URL macro instead
  .\"         
  .\"
  .de LINK
***************
*** 62,68 ****
  .        HTML <a href=\\$2>\\$1</a>
  .   \}
  .   el \{\
! \fI\\$1\s-2 \fB<ftp:\\$2>\fP\s+2
  .   \}
  ..
  .\"
--- 74,80 ----
  .        HTML <a href=\\$2>\\$1</a>
  .   \}
  .   el \{\
! $1 (<ftp:\\$2>)
  .   \}
  ..
  .\"
***************
*** 86,97 ****
  .        \}
  .   \}
  .   el \{\
- .        ie '\\$2'' \{\
  \s-2\fB<email:\\$1>\fP\s+2
- .        \}
- .        el \{\
- \fI\\$1\s-2 \fB<email:\\$2>\fP\s+2
- .        \}
  .   \}
  ..
  .\"
--- 98,104 ----
diff -r -c groff/grohtml/ChangeLog groff.html/grohtml/ChangeLog
*** groff/grohtml/ChangeLog     Mon Sep 27 14:06:43 1999
--- groff.html/grohtml/ChangeLog        Wed Oct  6 08:55:19 1999
***************
*** 1,8 ****
  1999-09-27  Werner LEMBERG  <address@hidden>
  
        * html.cc (move_horizontal): Fonts have changed one character too
        late.
! 
  1999-09-26  Werner LEMBERG  <address@hidden>
  
        * grohtml.man: Minor cosmetic fixes.
--- 1,21 ----
+ 1999-10-5  Gaius Mulley <address@hidden>
+ 
+       * introduced command line options -r to determine the resolution
+       of generated images, -I to determine the format of images generated.
+       Fixed many bugs to do with superscripts, subscripts, indentation,
+       font changes and extraneous spaces. Fixed bug in determining the
+       range of polygons and splines. Updated the manual page to reflect
+       the new options. The default image type is png format, however
+       this will only work if you have a gs with a png output device.
+       If you don't have a gs with this ability you can either reconfigure
+       html to generate gif images by default (alter a #define in html.cc).
+       Or alternatively you can use the -Igif option.
+ 
  1999-09-27  Werner LEMBERG  <address@hidden>
  
        * html.cc (move_horizontal): Fonts have changed one character too
        late.
!       
  1999-09-26  Werner LEMBERG  <address@hidden>
  
        * grohtml.man: Minor cosmetic fixes.
diff -r -c groff/grohtml/grohtml.man groff.html/grohtml/grohtml.man
*** groff/grohtml/grohtml.man   Sun Sep 26 09:38:20 1999
--- groff.html/grohtml/grohtml.man      Wed Oct  6 09:05:02 1999
***************
*** 32,37 ****
--- 32,41 ----
  ] [
  .BI \-F dir
  ] [
+ .BI \-I imagetype
+ ] [
+ .BI \-r resolution
+ ] [
  .IR files \|.\|.\|.
  ]
  .SH DESCRIPTION
***************
*** 84,89 ****
--- 88,94 ----
  By using this flag and the -m flag below
  .B grohtml
  will treat the html viewer as a printer, not a formatter.
+ .TP
  .B \-m
  leave margins alone.
  .B grohtml
***************
*** 97,102 ****
--- 102,116 ----
  is the name of the device, usually
  .BR html .
  .TP
+ .BI \-I imagetype
+ select the type of image generated when grohtml encounters an equation, table 
or picture.
+ By default this is png256. Legal image types are: gif and any of the png 
formats which
+ are supported by ghostscript gs(1).
+ .TP
+ .BI \-r resolution
+ select the resolution for all images. By default this is 80 pixels per inch. 
Example: -r100
+ indicates 100 pixels per inch.
+ .TP
  .B \-v
  Print the version number.
  .TP
***************
*** 111,119 ****
  .B BI
  mounted at font positions 1 to 4.
  .SH DEPENDENCIES
! grohtml is dependent upon grops, gs, ppmtogif and ppmquant which are
! invoked to generate all gif files.
! Gif files are generated whenever a table, picture, equation or line is
  encountered.
  .SH BUGS
  This is still fairly alpha, nevertheless I find it useful.
--- 125,136 ----
  .B BI
  mounted at font positions 1 to 4.
  .SH DEPENDENCIES
! grohtml is dependent upon grops and gs.
! If grohtml has been configured to generate gif files then it is
! further dependant upon, ppmtogif and ppmquant.
! However if it has been configured to generate png files (the default)
! then it is dependant upon gs having a png output device.
! Images are generated whenever a table, picture, equation or line is
  encountered.
  .SH BUGS
  This is still fairly alpha, nevertheless I find it useful.
diff -r -c groff/grohtml/html.cc groff.html/grohtml/html.cc
*** groff/grohtml/html.cc       Mon Sep 27 14:06:43 1999
--- groff.html/grohtml/html.cc  Wed Oct  6 08:45:35 1999
***************
*** 43,61 ****
  #   define FALSE (1==0)
  #endif
  
! #define MAX_TEMP_NAME      1024
! #define MAX_STRING_LENGTH  4096
  
! #define Y_FUDGE_MARGIN     +0.83
! #define A4_PAGE_LENGTH     (11.6944-Y_FUDGE_MARGIN)
! #define GIF_RES            80
! #define GIF_BOARDER_PIXELS 10
  
  
! static int debug_on   = FALSE;
! static int guess_on   =  TRUE;
! static int margin_on  = FALSE;
! static int auto_on    = FALSE;
  
  static int linewidth = -1;
  
--- 43,79 ----
  #   define FALSE (1==0)
  #endif
  
! #define MAX_TEMP_NAME                1024
! #define MAX_STRING_LENGTH            4096
  
! #define Y_FUDGE_MARGIN              +0.83
! #define A4_PAGE_LENGTH              (11.6944-Y_FUDGE_MARGIN)
! #define DEFAULT_IMAGE_RES            80
! #define IMAGE_BOARDER_PIXELS         10
  
+ /*
+  *  Only uncomment one of the following to determine default image type.
+  */
+ 
+ #define IMAGE_DEFAULT_PNG
+ /* #define IMAGE_DEFAULT_GIF */
  
! 
! #if defined(IMAGE_DEFAULT_GIF)
! static enum { gif, png } image_type = gif;
! static char *image_device           = "gif";
! #elif defined(IMAGE_DEFAULT_PNG)
! static enum { gif, png } image_type = png;
! static char *image_device           = "png256";
! #else
! #   error "you must define either IMAGE_DEFAULT_GIF or IMAGE_DEFAULT_PNG"
! #endif
! 
! static int debug_on                 = FALSE;
! static int guess_on                 =  TRUE;
! static int margin_on                = FALSE;
! static int auto_on                  = FALSE;
! static int image_res                = DEFAULT_IMAGE_RES;
  
  static int linewidth = -1;
  
***************
*** 258,264 ****
    int        is_less (text_glob *a, text_glob *b);
    text_glob  (style *s, char *string, unsigned int length,
              int min_vertical, int min_horizontal,
!             int max_vertical, int max_horizontal, int is_command);
    text_glob  (void);
    ~text_glob (void);
  
--- 276,282 ----
    int        is_less (text_glob *a, text_glob *b);
    text_glob  (style *s, char *string, unsigned int length,
              int min_vertical, int min_horizontal,
!             int max_vertical, int max_horizontal, int is_command, int 
is_html);
    text_glob  (void);
    ~text_glob (void);
  
***************
*** 266,285 ****
    char           *text_string;
    unsigned int    text_length;
    int             minv, maxv, minh, maxh;
!   int             is_raw_command;
  };
  
  text_glob::text_glob (style *s, char *string, unsigned int length,
                      int min_vertical, int min_horizontal,
!                     int max_vertical, int max_horizontal, int is_command)
    : text_style(*s), text_string(string), text_length(length),
      minv(min_vertical), minh(min_horizontal), maxv(max_vertical), 
maxh(max_horizontal),
!     is_raw_command(is_command)
  {
  }
  
  text_glob::text_glob ()
!   : text_string(0), text_length(0), minv(-1), maxv(-1), minh(-1), maxh(-1)
  {
  }
  
--- 284,305 ----
    char           *text_string;
    unsigned int    text_length;
    int             minv, maxv, minh, maxh;
!   int             is_raw_command;       // should the text be sent directly 
to the device?
!   int             is_html_command;      // is the raw command definitely for 
the html device ie not an eqn?
  };
  
  text_glob::text_glob (style *s, char *string, unsigned int length,
                      int min_vertical, int min_horizontal,
!                     int max_vertical, int max_horizontal, int is_command, int 
is_html)
    : text_style(*s), text_string(string), text_length(length),
      minv(min_vertical), minh(min_horizontal), maxv(max_vertical), 
maxh(max_horizontal),
!     is_raw_command(is_command), is_html_command(is_html)
  {
  }
  
  text_glob::text_glob ()
!   : text_string(0), text_length(0), minv(-1), maxv(-1), minh(-1), maxh(-1),
!     is_raw_command(FALSE), is_html_command(FALSE)
  {
  }
  
***************
*** 384,389 ****
--- 404,410 ----
    void                        make_new_region          (graphic_glob *g);
    int                         has_line                 (region_glob *r);
    int                         has_word                 (region_glob *r);
+   int                         no_raw_commands          (int minv, int maxv);
  
    // and the data
  
***************
*** 408,414 ****
  {
    if (length > 0) {
      text_glob *g=new text_glob(s, buffer.add_string(string, length), length,
!                              min_vertical, min_horizontal, max_vertical, 
max_horizontal, FALSE);
      if (is_in_graphic) {
        region_words.add(g);
      } else {
--- 429,435 ----
  {
    if (length > 0) {
      text_glob *g=new text_glob(s, buffer.add_string(string, length), length,
!                              min_vertical, min_horizontal, max_vertical, 
max_horizontal, FALSE, FALSE);
      if (is_in_graphic) {
        region_words.add(g);
      } else {
***************
*** 417,423 ****
    }
  }
  
- 
  /*
   *  add_html_command - it only makes sense to add html commands when we are 
not inside
   *                     a graphical entity.
--- 438,443 ----
***************
*** 429,435 ****
  {
    if ((length > 0) && (! is_in_graphic)) {
      text_glob *g=new text_glob(s, buffer.add_string(string, length), length,
!                              min_vertical, min_horizontal, max_vertical, 
max_horizontal, TRUE);
      words.add(g);
    }
  }
--- 449,455 ----
  {
    if ((length > 0) && (! is_in_graphic)) {
      text_glob *g=new text_glob(s, buffer.add_string(string, length), length,
!                              min_vertical, min_horizontal, max_vertical, 
max_horizontal, TRUE, TRUE);
      words.add(g);
    }
  }
***************
*** 445,456 ****
  {
    if ((length > 0) && (is_in_graphic)) {
      text_glob *g=new text_glob(s, buffer.add_string(string, length), length,
!                              min_vertical, min_horizontal, max_vertical, 
max_horizontal, TRUE);
!     if (is_in_graphic) {
!       region_words.add(g);
!     } else {
!       words.add(g);
!     }
    }
  }
  
--- 465,472 ----
  {
    if ((length > 0) && (is_in_graphic)) {
      text_glob *g=new text_glob(s, buffer.add_string(string, length), length,
!                              min_vertical, min_horizontal, max_vertical, 
max_horizontal, TRUE, FALSE);
!     region_words.add(g);
    }
  }
  
***************
*** 1099,1106 ****
    int           left_margin_indent;
    int           right_margin_indent;
    int           need_one_newline;
!   char          gif_name[MAX_STRING_LENGTH];
!   int           gif_number;
    int           graphic_level;
  
    int           start_region_vpos;
--- 1115,1123 ----
    int           left_margin_indent;
    int           right_margin_indent;
    int           need_one_newline;
!   int           in_paragraph;
!   char          image_name[MAX_STRING_LENGTH];
!   int           image_number;
    int           graphic_level;
  
    int           start_region_vpos;
***************
*** 1142,1164 ****
    void  write_html_font_face     (const char *fontname, const char *left, 
const char *right);
    void  write_html_font_type     (const char *fontname, const char *left, 
const char *right);
    void  html_change_font         (text_glob *g, const char *fontname, int 
size);
!   char *html_position_text (text_glob *g);
    void  html_position_region     (void);
    void  troff_change_font        (const char *fontname, int size, int 
font_no);
    void  troff_position_text      (text_glob *g);
    int   is_on_same_line          (text_glob *g);
    int   looks_like_subscript     (text_glob *g);
    int   looks_like_superscript   (text_glob *g);
!   void  convert_to_gif           (char *name);
    void  write_title              (int in_head);
    void  find_title               (void);
    int   is_bold                  (text_glob *g);
    void  write_header             (void);
    void  determine_header_level   (void);
    void  build_header             (text_glob *g);
    int   is_whole_line_bold       (text_glob *g);
    int   processed_header         (text_glob *g);
!   void  make_new_gif_name        (void);
    void  create_temp_name         (char *name, char *extension);
    void  calculate_region_margins (region_glob *r);
    void  remove_redundant_regions (void);
--- 1159,1185 ----
    void  write_html_font_face     (const char *fontname, const char *left, 
const char *right);
    void  write_html_font_type     (const char *fontname, const char *left, 
const char *right);
    void  html_change_font         (text_glob *g, const char *fontname, int 
size);
!   char *html_position_text       (text_glob *g);
    void  html_position_region     (void);
    void  troff_change_font        (const char *fontname, int size, int 
font_no);
    void  troff_position_text      (text_glob *g);
    int   is_on_same_line          (text_glob *g);
    int   looks_like_subscript     (text_glob *g);
    int   looks_like_superscript   (text_glob *g);
!   void  begin_paragraph          (void);
!   void  end_paragraph            (void);
!   void  html_newline             (void);
!   void  convert_to_image         (char *name);
    void  write_title              (int in_head);
    void  find_title               (void);
    int   is_bold                  (text_glob *g);
    void  write_header             (void);
    void  determine_header_level   (void);
    void  build_header             (text_glob *g);
+   void  make_html_indent         (int indent);
    int   is_whole_line_bold       (text_glob *g);
    int   processed_header         (text_glob *g);
!   void  make_new_image_name      (void);
    void  create_temp_name         (char *name, char *extension);
    void  calculate_region_margins (region_glob *r);
    void  remove_redundant_regions (void);
***************
*** 1202,1210 ****
    end_region_vpos(0),
    end_region_hpos(0),
    need_one_newline(0),
!   gif_number(0),
    graphic_level(0),
!   cutoff_heading(100)
  {
    tempfp = xtmpfile();
    html.set_file(tempfp);
--- 1223,1232 ----
    end_region_vpos(0),
    end_region_hpos(0),
    need_one_newline(0),
!   image_number(0),
    graphic_level(0),
!   cutoff_heading(100),
!   in_paragraph(0)
  {
    tempfp = xtmpfile();
    html.set_file(tempfp);
***************
*** 1317,1330 ****
  
  
  /*
!  *  make_new_gif_name - creates a new file name ready for a gif file.
!  *                      it leaves the .gif extension off.
   */
  
! void html_printer::make_new_gif_name (void)
  {
!   gif_number++;
!   sprintf(gif_name, "groff-html-%d-%d", gif_number, getpid());
  }
  
  /*
--- 1339,1352 ----
  
  
  /*
!  *  make_new_image_name - creates a new file name ready for a image file.
!  *                        it leaves the extension off.
   */
  
! void html_printer::make_new_image_name (void)
  {
!   image_number++;
!   sprintf(image_name, "groff-html-%d-%d", image_number, getpid());
  }
  
  /*
***************
*** 1340,1348 ****
        html.put_string("</title>\n");
      } else {
        title.has_been_written = TRUE;
!       html.put_string("<p><h1 align=center>");
        html.put_string(title.text);
!       html.put_string("</h1><p>\n");
      }
    }
  }
--- 1362,1370 ----
        html.put_string("</title>\n");
      } else {
        title.has_been_written = TRUE;
!       html.put_string("<h1 align=center>");
        html.put_string(title.text);
!       html.put_string("</h1>\n");
      }
    }
  }
***************
*** 1389,1394 ****
--- 1411,1418 ----
           */
          title.has_been_found = TRUE;
          return;
+       } else if (t->is_raw_command) {
+         // skip raw commands
        } else if ((!found_title_start) && (t->minh > left_margin_indent) &&
                   ((start_region == -1) || (t->maxv < start_region))) {
          start_title_vpos     = t->minv;
***************
*** 1428,1433 ****
--- 1452,1500 ----
    }
  }
  
+ /*
+  *  html_newline - generates a newline <br>
+  */
+ 
+ void html_printer::html_newline (void)
+ {
+   int r        =font::res;
+   int height   = output_style.point_size*r/72;
+ 
+   if (in_paragraph) {
+     // safe to generate a pretty newline
+     html.put_string("<br>\n");
+   } else {
+     html.put_string("<br>");
+   }
+   output_vpos += height;
+ }
+ 
+ /*
+  *  begin_paragraph - starts a new paragraph. It does nothing if a paragraph
+  *                    has already been started.
+  */
+ 
+ void html_printer::begin_paragraph (void)
+ {
+   if (! in_paragraph) {
+     html.put_string("<p>");
+     in_paragraph = TRUE;
+   }
+ }
+ 
+ /*
+  *  end_paragraph - end the current paragraph. It does nothing if a paragraph
+  *                  has not been started.
+  */
+ 
+ void html_printer::end_paragraph (void)
+ {
+   if (in_paragraph) {
+     html.put_string("</p>");
+     in_paragraph = FALSE;
+   }
+ }
  
  /*
   *  calculate_margin - runs through the words and graphics globs
***************
*** 1703,1708 ****
--- 1770,1798 ----
  
  
  /*
+  *  no_raw_commands - returns TRUE if no html raw commands exist between
+  *                    minv and maxv.
+  */
+ 
+ int page::no_raw_commands (int minv, int maxv)
+ {
+   text_glob *g;
+ 
+   if (! words.is_empty()) {
+     words.start_from_head();
+     do {
+       g = words.get_data();
+       if ((g->is_raw_command) && (g->is_html_command) &&
+         (is_intersection(g->minv, g->maxv, minv, maxv))) {
+       return( FALSE );
+       }
+       words.move_right();
+     } while (! words.is_equal_to_head());
+   }
+   return( TRUE );
+ }
+ 
+ /*
   *  can_grow_region - returns TRUE if a region exists which can be extended
   *                    to include graphic_glob *g. The region is extended.
   */
***************
*** 1716,1722 ****
      regions.start_from_head();
      do {
        r = regions.get_data();
!       if (is_intersection(g->minv, g->maxv, r->minv, r->maxv+quarter_inch)) {
  #if defined(DEBUGGING)
        stop();
        printf("r minh=%d  minv=%d  maxh=%d  maxv=%d\n",
--- 1806,1814 ----
      regions.start_from_head();
      do {
        r = regions.get_data();
!       // must prevent grohtml from growing a region through a html raw command
!       if (is_intersection(g->minv, g->maxv, r->minv, r->maxv+quarter_inch) &&
!         (no_raw_commands(r->minv, r->maxv+quarter_inch))) {
  #if defined(DEBUGGING)
        stop();
        printf("r minh=%d  minv=%d  maxh=%d  maxv=%d\n",
***************
*** 1881,1887 ****
    }
  }
  
! void html_printer::convert_to_gif (char *name)
  {
    char buffer[1024];
  
--- 1973,1979 ----
    }
  }
  
! void html_printer::convert_to_image (char *name)
  {
    char buffer[1024];
  
***************
*** 1891,1902 ****
    }
    system(buffer);
  
!   sprintf(buffer,
!         "echo showpage | gs -q -dSAFER -sDEVICE=ppmraw -r%d -g%dx%d 
-sOutputFile=- %s.ps - | ppmquant 256  2> /dev/null | ppmtogif  2> /dev/null > 
%s.gif \n",
!         GIF_RES,
!         
(end_region_hpos-start_region_hpos)*GIF_RES/font::res+GIF_BOARDER_PIXELS,
!         
(end_region_vpos-start_region_vpos)*GIF_RES/font::res+GIF_BOARDER_PIXELS,
!         name, gif_name);
    if (debug_on) {
      fprintf(stderr, "%s", buffer);
    }
--- 1983,2004 ----
    }
    system(buffer);
  
!   if (image_type == gif) {
!     sprintf(buffer,
!           "echo showpage | gs -q -dSAFER -sDEVICE=ppmraw -r%d -g%dx%d 
-sOutputFile=- %s.ps - | ppmquant 256  2> /dev/null | ppmtogif  2> /dev/null > 
%s.gif \n",
!           image_res,
!           
(end_region_hpos-start_region_hpos)*image_res/font::res+IMAGE_BOARDER_PIXELS,
!           
(end_region_vpos-start_region_vpos)*image_res/font::res+IMAGE_BOARDER_PIXELS,
!           name, image_name);
!   } else {
!     sprintf(buffer,
!           "echo showpage | gs -q -dSAFER -sDEVICE=%s -r%d -g%dx%d 
-sOutputFile=- %s.ps - 2> /dev/null > %s.png \n",
!           image_device,
!           image_res,
!           
(end_region_hpos-start_region_hpos)*image_res/font::res+IMAGE_BOARDER_PIXELS,
!           
(end_region_vpos-start_region_vpos)*image_res/font::res+IMAGE_BOARDER_PIXELS,
!           name, image_name);
!   }
    if (debug_on) {
      fprintf(stderr, "%s", buffer);
    }
***************
*** 1918,1925 ****
  
  void html_printer::create_temp_name (char *name, char *extension)
  {
!   make_new_gif_name();
!   sprintf(name, "/tmp/%s.%s", gif_name, extension);
  }
  
  void html_printer::display_globs (int is_to_html)
--- 2020,2027 ----
  
  void html_printer::create_temp_name (char *name, char *extension)
  {
!   make_new_image_name();
!   sprintf(name, "/tmp/%s.%s", image_name, extension);
  }
  
  void html_printer::display_globs (int is_to_html)
***************
*** 1940,1945 ****
--- 2042,2048 ----
      f = create_file(name);
      troff.set_file(f);
      prologue();
+     output_style.f = 0;
    }
    if (! page_contents->words.is_empty()) {
      page_contents->words.start_from_head();
***************
*** 1964,1969 ****
--- 2067,2077 ----
        something = TRUE;
        }
        t = page_contents->words.move_right_get_data();
+ #if 0
+       if ((t != 0) && (strcmp(t->text_string, "Published") == 0)) {
+       stop();
+       }
+ #endif
      } else {
        if ((g == 0) || (t == 0)) {
        // hmm nothing to print out...
***************
*** 1986,2000 ****
    if ((! is_to_html) && (f != 0)) {
      fclose(troff.get_file());
      if (something) {
!       convert_to_gif(name);
!   
        html.put_string("<img src=\"");
!       html.put_string(gif_name);
!       html.put_string(".gif\"><br>\n");
  
!       output_vpos = end_region_vpos;
!       output_hpos = 0;
        need_one_newline = FALSE;
      }
      // unlink(name);  // remove troff file
    }
--- 2094,2114 ----
    if ((! is_to_html) && (f != 0)) {
      fclose(troff.get_file());
      if (something) {
!       convert_to_image(name);
! 
        html.put_string("<img src=\"");
!       html.put_string(image_name);
!       if (image_type == gif) {
!       html.put_string(".gif\">");
!       } else {
!       html.put_string(".png\">");
!       }
!       html_newline();
  
!       output_vpos      = end_region_vpos;
!       output_hpos      = 0;
        need_one_newline = FALSE;
+       output_style.f   = 0;
      }
      // unlink(name);  // remove troff file
    }
***************
*** 2015,2134 ****
  
    traverse_page_regions();
    terminate_current_font();
!   html.put_string("<br>\n");
    
    // move onto a new page
- 
    delete page_contents;
    page_contents = new page;
  }
  
- #if 0
- void html_printer::change_font (const char *name, int size)
- {
-   char buffer[1024];
-   int  height;
-   int  temp_vpos=output_vpos;
- 
-   flush_font();
- 
-   if (temp_vpos != sbuf_vpos) {
-     if (temp_vpos == -1) {
-       temp_vpos = sbuf_vpos;
-     }
- 
-     if (auto_on) {
-       height = (size+2)*font::res/72;
- 
-       if (more_than_line_break(temp_vpos, sbuf_vpos, height)) {
-       if (sbuf_start_hpos > res) {
-         // looks like the end of an indented paragraph will suffice here
-         html.put_symbol("</p>\n");
-       }
-       // now check to see if more white space is requred
-       while ((temp_vpos < sbuf_vpos) && (more_than_line_break(temp_vpos, 
sbuf_vpos, 2*height))) {
-         html.put_symbol("<br>\n");
-         temp_vpos += height*2;
-       }
-       if (sbuf_start_hpos > res) {
-         // looks likes the start of an indented paragraph
-         html.put_symbol("<p>");
-       }
-       if (temp_vpos < sbuf_vpos+height) {
-         temp_vpos += height;
-       }
-       }
-     } else {
-       height = (size+0)*font::res/72;
- 
-       // must put a new line out when using not using html auto formatting
-       html.put_symbol("\n");
-       temp_vpos += height;
-       while ((temp_vpos < sbuf_vpos) && (more_than_line_break(temp_vpos, 
sbuf_vpos, height))) {
-       html.put_symbol("\n");
-       temp_vpos += height;
-       }
-     }
-   }
-   html.put_symbol("<span style=\"font-family:");
-   switch (name[0]) {
- 
-   case 'C':  html.put_symbol("courier;");
-              break;
- 
-   case 'H':  html.put_symbol("helvetica;");
-              break;
-   case 'T':  html.put_symbol("roman;");
-              break;
-   default:   html.put_symbol("helvetica;");
-              break;
- 
-   }
-   sprintf(buffer, "font-size: %dpt;", size);
-   html.put_symbol(buffer);
-   html.put_symbol("font-style:");
- 
-   switch (name[1]) {
- 
-   case 'I':  html.put_symbol("italic;");
-              break;
-   case 'B':  html.put_symbol("bold;");
-              break;
-   default :  html.put_symbol("normal;");
-              break;
-   }
-   if (auto_on) {
-     if (font::res < sbuf_start_hpos) {
-       // --fixme-- font::res must be altered to leftmost margin later
-       int w = sbuf_style.f->get_space_width(sbuf_style.point_size);
- 
-       if (output_hpos == -1) {
-       output_hpos = font::res;
-       }
-       if (sbuf_start_hpos-output_hpos > w) {
-       html.put_symbol("text-indent:");
-       html.put_float(((double)(sbuf_start_hpos-output_hpos)/((double)75.0)));
-       html.put_symbol("in;");
-       }
-     }
-   } else {
-     if ((output_vpos == sbuf_vpos) &&
-       (output_hpos != -1) && (output_hpos <= sbuf_start_hpos)) {
-       if (sbuf_start_hpos-output_hpos != 0) {
-       html.put_symbol("text-indent:");
-       html.put_float(((double)(sbuf_start_hpos-output_hpos)/((double)75.0)));
-       html.put_symbol("in;");
-       }
-     } else {
-       html.put_symbol("text-indent:");
-       html.put_float(((double)sbuf_start_hpos/((double)75.0)));
-       html.put_symbol("in;");
-     }
-   }
-   html.put_symbol("\">");
- }
- #endif
- 
  static int convertSizeToHTML (int size)
  {
    if (size < 6) {
--- 2129,2144 ----
  
    traverse_page_regions();
    terminate_current_font();
!   if (need_one_newline) {
!     html_newline();
!   }
!   end_paragraph();
    
    // move onto a new page
    delete page_contents;
    page_contents = new page;
  }
  
  static int convertSizeToHTML (int size)
  {
    if (size < 6) {
***************
*** 2189,2208 ****
        write_html_font_type(oldfontname, "</", ">");
      }
    }
!   if ((! g->is_raw_command) && (fontname != 0)) {
      // now emit the size if it has changed
!     if ((output_style.f == 0) || (output_style.point_size != size)) {
        sprintf(buffer, "<font size=%d>", convertSizeToHTML(size));
        html.put_string(buffer);
      }
  
!     // now emit the new font
!     write_html_font_face(fontname, "<", ">");
    
!     // now emit the new font type
!     write_html_font_type(fontname, "<", ">");
  
!     output_style = g->text_style;  // remember style for next time
    } else {
      output_style.f = 0;   // no style at present
    }
--- 2199,2221 ----
        write_html_font_type(oldfontname, "</", ">");
      }
    }
!   if (fontname != 0) {
      // now emit the size if it has changed
!     if (((output_style.f == 0) || (output_style.point_size != size)) && (size 
!= 0)) {
        sprintf(buffer, "<font size=%d>", convertSizeToHTML(size));
        html.put_string(buffer);
+       output_style.point_size = size;  // and remember the size
      }
  
!     if (! g->is_raw_command) {
!       // now emit the new font
!       write_html_font_face(fontname, "<", ">");
    
!       // now emit the new font type
!       write_html_font_type(fontname, "<", ">");
  
!       output_style = g->text_style;  // remember style for next time
!     }
    } else {
      output_style.f = 0;   // no style at present
    }
***************
*** 2216,2222 ****
        const char *fontname=0;
        int   size=0;
  
!       if ((! g->is_raw_command) && (g->text_style.f != 0)) {
        fontname = g->text_style.f->get_name();
        size     = (font::res/(72*font::sizescale))*g->text_style.point_size;
  
--- 2229,2235 ----
        const char *fontname=0;
        int   size=0;
  
!       if (g->text_style.f != 0) {
        fontname = g->text_style.f->get_name();
        size     = (font::res/(72*font::sizescale))*g->text_style.point_size;
  
***************
*** 2244,2254 ****
--- 2257,2275 ----
  }
  
  
+ /*
+  *  is_bold - returns TRUE if the text inside, g, is using a bold face.
+  *            It returns FALSE is g contains a raw html command, even if this 
uses
+  *            a bold font.
+  */
+ 
  int html_printer::is_bold (text_glob *g)
  {
    if (g->text_style.f == 0) {
      // unknown font
      return( FALSE );
+   } else if (g->is_raw_command) {
+     return( FALSE );
    } else {
      const char *fontname = g->text_style.f->get_name();
      
***************
*** 2280,2285 ****
--- 2301,2307 ----
      if (cutoff_heading+2 > header.header_level) {
        // firstly we must terminate any font and type faces
        terminate_current_font();
+       end_paragraph();
  
        // secondly we generate a tag
        html.put_string("<a name=\"");
***************
*** 2290,2311 ****
  
        header.no_of_headings++;
  
!       text_glob *g=new text_glob(&st, 
header.headings.add_string(header.header_buffer, strlen(header.header_buffer)),
                                 strlen(header.header_buffer),
                                 header.no_of_headings, header.header_level,
                                 header.no_of_headings, header.header_level,
!                                FALSE);
        header.headers.add(g);   // and add this header to the header list
      }
!     
      // and now we issue the real header
!     html.put_string("</p><h");
      html.put_number(header.header_level);
      html.put_string(">");
      html.put_string(header.header_buffer);
      html.put_string("</h");
      html.put_number(header.header_level);
!     html.put_string("><p>");
      header.written_header = TRUE;
    }
  }
--- 2312,2337 ----
  
        header.no_of_headings++;
  
!       text_glob *g=new text_glob(&st,
!                                
header.headings.add_string(header.header_buffer, strlen(header.header_buffer)),
                                 strlen(header.header_buffer),
                                 header.no_of_headings, header.header_level,
                                 header.no_of_headings, header.header_level,
!                                FALSE, FALSE);
        header.headers.add(g);   // and add this header to the header list
      }
! 
!     end_paragraph();
      // and now we issue the real header
!     html.put_string("<h");
      html.put_number(header.header_level);
      html.put_string(">");
      html.put_string(header.header_buffer);
      html.put_string("</h");
      html.put_number(header.header_level);
!     html.put_string(">");
!     need_one_newline = FALSE;
!     begin_paragraph();
      header.written_header = TRUE;
    }
  }
***************
*** 2347,2353 ****
  
  void html_printer::build_header (text_glob *g)
  {
!   int current_vpos=g->minv;
  
    strcpy(header.header_buffer, "");
    do {
--- 2373,2381 ----
  
  void html_printer::build_header (text_glob *g)
  {
!   int current_vpos = g->minv;
!   int r            = font::res;
!   int height       = g->text_style.point_size*r/72;
  
    strcpy(header.header_buffer, "");
    do {
***************
*** 2361,2370 ****
  
    determine_header_level();
    // finally set the output to neutral for after the header
    g = page_contents->words.get_data();
!   output_vpos = g->minv;
!   output_hpos = g->minh;
!   page_contents->words.move_left();  // so that next time we use old g
    need_one_newline = FALSE;
  }
  
--- 2389,2400 ----
  
    determine_header_level();
    // finally set the output to neutral for after the header
+ 
    g = page_contents->words.get_data();
!   output_vpos = g->minv;                // set output_vpos to the next line 
since
!   output_hpos = left_margin_indent;     // html header forces a newline anyway
!   page_contents->words.move_left();     // so that next time we use old g
! 
    need_one_newline = FALSE;
  }
  
***************
*** 2416,2442 ****
  }
  
  /*
!  *  move_horizontal - moves right into the position, g.
   */
  
  void html_printer::move_horizontal (text_glob *g)
  {
!   if (! g->is_raw_command) {
      int w = g->text_style.f->get_space_width(g->text_style.point_size);
  
      if (w == 0) {
        fatal("space width is zero");
      }
!     if ((w <= g->minh-output_hpos) || (! is_punctuation(g->text_string, 
g->text_length))) {
!       html.put_string(" ");
!       output_hpos += 2*w; //  * 3 / 2;
!       while (output_hpos+w <= g->minh) {
        html.put_string(" ");
        output_hpos += w;
        }
-       output_hpos = g->maxh+(output_hpos-g->minh);   /* --fixme-- */
-       output_vpos = g->minv;
      }
      change_font(g, TRUE);
    }
  }
--- 2446,2477 ----
  }
  
  /*
!  *  move_horizontal - moves right into the position, g->minh.
   */
  
  void html_printer::move_horizontal (text_glob *g)
  {
!   if (g->text_style.f != 0) {
      int w = g->text_style.f->get_space_width(g->text_style.point_size);
  
      if (w == 0) {
        fatal("space width is zero");
      }
!     if ((output_hpos == left_margin_indent) && (g->minh > output_hpos)) {
!       make_html_indent(g->minh-output_hpos);
!     } else {
!       if (g->minh > output_hpos) {
!       html.put_string(" ");
!       output_hpos += w;
!       }
!       while (output_hpos < g->minh) {
        html.put_string(" ");
        output_hpos += w;
        }
      }
+     output_hpos = g->maxh;
+     output_vpos = g->minv;
+ 
      change_font(g, TRUE);
    }
  }
***************
*** 2457,2469 ****
  
  int html_printer::is_on_same_line (text_glob *g)
  {
!   if (strcmp(g->text_string, "speed") == 0) {
!     stop();
!   }
!   return( is_intersection(output_vpos, 
output_vpos+g->text_style.point_size*font::res/72, g->minv, g->maxv) );
  }
  
  
  char *html_printer::html_position_text (text_glob *g)
  {
    int  height;
--- 2492,2514 ----
  
  int html_printer::is_on_same_line (text_glob *g)
  {
!   return( is_intersection(output_vpos, 
output_vpos+g->text_style.point_size*font::res/72-1, g->minv, g->maxv) );
  }
  
  
+ /*
+  *  make_html_indent - creates a relative indentation.
+  */
+ 
+ void html_printer::make_html_indent (int indent)
+ {
+   int  r=font::res;
+ 
+   html.put_string("<span style=\" text-indent: ");
+   html.put_float(((double)(indent)/((double)r)));
+   html.put_string("in;\"></span>");
+ }
+ 
  char *html_printer::html_position_text (text_glob *g)
  {
    int  height;
***************
*** 2471,2486 ****
--- 2516,2539 ----
    int  r        =font::res;
    char *postword=0;
  
+   begin_paragraph();
    if (is_on_same_line(g)) {
+     // check whether the font was reset after generating an image
+     if (output_style.f == 0) {
+       change_font(g, TRUE);
+     }
      if (looks_like_subscript(g)) {
  
        g->text_style.point_size = output_style.point_size;
+       g->minv                  = output_vpos;   // this ensures that 
output_vpos doesn't alter
+                                                 // which allows multiple 
subscripted words
  
        html.put_string("<sub>");
        postword = "</sub>";
      } else if (looks_like_superscript(g)) {
  
        g->text_style.point_size = output_style.point_size;
+       g->minv                  = output_vpos;
  
        html.put_string("<sup>");
        postword = "</sup>";
***************
*** 2497,2517 ****
      height = g->text_style.point_size*r/72;
  
      if (need_one_newline) {
!       html.put_string("<br>\n");
        temp_vpos += height;
      } else {
        need_one_newline = TRUE;
      }
      
      while ((temp_vpos < g->minv) && (more_than_line_break(temp_vpos, g->minv, 
height))) {
!       html.put_string("<br>\n");
        temp_vpos += height;
      }
!     if (! processed_header(g)) {
        if (g->minh-left_margin_indent != 0) {
!       html.put_string("<span style=\" text-indent: ");
!       html.put_float(((double)(g->minh-left_margin_indent)/((double)r)));
!       html.put_string("in;\"></span>");
        }
        change_font(g, TRUE);
      }
--- 2550,2573 ----
      height = g->text_style.point_size*r/72;
  
      if (need_one_newline) {
!       html_newline();
        temp_vpos += height;
      } else {
        need_one_newline = TRUE;
      }
      
      while ((temp_vpos < g->minv) && (more_than_line_break(temp_vpos, g->minv, 
height))) {
!       html_newline();
        temp_vpos += height;
      }
!     if (processed_header(g)) {
!       // we must not alter output_vpos as we have peeped at the next word
!       // and set vpos to this - to ensure we do not generate a <br> after
!       // a heading. (The html heading automatically generates a line break)
!       return( postword );
!     } else {
        if (g->minh-left_margin_indent != 0) {
!       make_html_indent(g->minh-left_margin_indent);
        }
        change_font(g, TRUE);
      }
***************
*** 2530,2535 ****
--- 2586,2592 ----
  
    if (output_style.point_size != 0) {
      if (output_vpos != start_region_vpos) {
+ 
        // graphic starts on a different line
        if (output_vpos == -1) {
        temp_vpos = start_region_vpos;
***************
*** 2539,2553 ****
  
        height = output_style.point_size*r/72;
        if (need_one_newline) {
!       html.put_string("<br>\n");
        } else {
        need_one_newline = TRUE;
        }
  
-       temp_vpos += height;
        while ((temp_vpos < start_region_vpos) &&
             (more_than_line_break(temp_vpos, start_region_vpos, height))) {
!       html.put_string("\n");
        temp_vpos += height;
        }
        if (start_region_hpos > left_margin_indent) {
--- 2596,2610 ----
  
        height = output_style.point_size*r/72;
        if (need_one_newline) {
!       html_newline();
!       temp_vpos += height;
        } else {
        need_one_newline = TRUE;
        }
  
        while ((temp_vpos < start_region_vpos) &&
             (more_than_line_break(temp_vpos, start_region_vpos, height))) {
!       html_newline();
        temp_vpos += height;
        }
        if (start_region_hpos > left_margin_indent) {
***************
*** 2575,2581 ****
  
  int html_printer::gs_x (int x)
  {
!   x += GIF_BOARDER_PIXELS/2;
    return((x-start_region_hpos)*postscript_res/font::res);
  }
  
--- 2632,2638 ----
  
  int html_printer::gs_x (int x)
  {
!   x += IMAGE_BOARDER_PIXELS/2;
    return((x-start_region_hpos)*postscript_res/font::res);
  }
  
***************
*** 2588,2594 ****
  {
    int yoffset=((int)(A4_PAGE_LENGTH*(double)font::res))-end_region_vpos;
  
!   y += GIF_BOARDER_PIXELS/2;
    return( (y+yoffset)*postscript_res/font::res );
  }
  
--- 2645,2651 ----
  {
    int yoffset=((int)(A4_PAGE_LENGTH*(double)font::res))-end_region_vpos;
  
!   y += IMAGE_BOARDER_PIXELS/2;
    return( (y+yoffset)*postscript_res/font::res );
  }
  
***************
*** 2637,2643 ****
    output_hpos = -1;
  }
  
- 
  void html_printer::html_display_word (text_glob *g)
  {
    char *postword=html_position_text(g);
--- 2694,2699 ----
***************
*** 2655,2661 ****
    header.written_header = FALSE;
  }
  
- 
  void html_printer::troff_display_word (text_glob *g)
  {
    troff_position_text(g);
--- 2711,2716 ----
***************
*** 2682,2687 ****
--- 2737,2748 ----
  {
    if (is_to_html) {
      html_display_word(g);
+   } else if ((g->is_raw_command) && (g->is_html_command)) {
+     // found a raw html command inside a graphic glob.
+     // We should emit the command to the html device, but of course we
+     // cannot place it correctly as we are dealing with troff words.
+     // Remember output_vpos will refer to troff and not html.
+     html.put_string((char *)g->text_string);
    } else {
      troff_display_word(g);
    }
***************
*** 2691,2697 ****
  /*
   *  this information may be better placed inside some of the font files
   *  in devhtml - however one must bare in mind that we need the ability
!  *  to write out to TWO devices (gif and html) and gif
   *  invokes ghostscript.
   */
  
--- 2752,2758 ----
  /*
   *  this information may be better placed inside some of the font files
   *  in devhtml - however one must bare in mind that we need the ability
!  *  to write out to TWO devices (image and html) and image
   *  invokes ghostscript.
   */
  
***************
*** 2825,2835 ****
      }
  
      int i;
      for (i=0; i<g->nopoints; i++) {
        troff.put_string(" ");
!       troff.put_number((g->point[i].x-g->xc)*postscript_res/font::res);
        troff.put_string(" ");
!       troff.put_number((g->point[i].y-g->yc)*postscript_res/font::res);
      }
      troff.put_string("\n");
    } else if (g->code == 'a') {
--- 2886,2900 ----
      }
  
      int i;
+     int xc=g->xc;
+     int yc=g->yc;
      for (i=0; i<g->nopoints; i++) {
        troff.put_string(" ");
!       troff.put_number((g->point[i].x-xc)*postscript_res/font::res);
        troff.put_string(" ");
!       troff.put_number((g->point[i].y-yc)*postscript_res/font::res);
!       xc = g->point[i].x;
!       yc = g->point[i].y;
      }
      troff.put_string("\n");
    } else if (g->code == 'a') {
***************
*** 2870,2881 ****
      troff.put_string("D~");
  
      int i;
! 
      for (i=0; i<g->nopoints; i++) {
        troff.put_string(" ");
!       troff.put_number(g->point[i].x*postscript_res/font::res);
        troff.put_string(" ");
!       troff.put_number(g->point[i].y*postscript_res/font::res);
      }
      troff.put_string("\n");
    }
--- 2935,2949 ----
      troff.put_string("D~");
  
      int i;
!     int xc=g->xc;
!     int yc=g->yc;
      for (i=0; i<g->nopoints; i++) {
        troff.put_string(" ");
!       troff.put_number((g->point[i].x-xc)*postscript_res/font::res);
        troff.put_string(" ");
!       troff.put_number((g->point[i].y-yc)*postscript_res/font::res);
!       xc = g->point[i].x;
!       yc = g->point[i].y;
      }
      troff.put_string("\n");
    }
***************
*** 3034,3043 ****
        while (i<np) {
        p[i+0] += oh;
        p[i+1] += ov;
        i      += 2;
        }
        // now store polygon in page
!       page_contents->add_polygon(code, np, p, oh, ov, env->size, fill);
      }
      break;
    case 'E':
--- 3102,3113 ----
        while (i<np) {
        p[i+0] += oh;
        p[i+1] += ov;
+       oh      = p[i+0];
+       ov      = p[i+1];
        i      += 2;
        }
        // now store polygon in page
!       page_contents->add_polygon(code, np, p, env->hpos, env->vpos, 
env->size, fill);
      }
      break;
    case 'E':
***************
*** 3093,3098 ****
--- 3163,3180 ----
        error("no arguments for spline");
        break;
        }
+       // firstly lets add our current position to spline
+       int oh=env->hpos;
+       int ov=env->vpos;
+       int i=0;
+ 
+       while (i<np) {
+       p[i+0] += oh;
+       p[i+1] += ov;
+       oh      = p[i+0];
+       ov      = p[i+1];
+       i      += 2;
+       }
        page_contents->add_spline('~', env->hpos, env->vpos, np, p, env->size, 
fill);
      }
      break;
***************
*** 3120,3126 ****
  void html_printer::begin_page(int n)
  {
    page_number            =  n;
!   html.begin_comment("Page:").comment_arg(itoa(page_number)).end_comment();;
    no_of_printed_pages++;
    
    output_style.f         =  0;
--- 3202,3208 ----
  void html_printer::begin_page(int n)
  {
    page_number            =  n;
!   html.begin_comment("Page: ").comment_arg(itoa(page_number)).end_comment();;
    no_of_printed_pages++;
    
    output_style.f         =  0;
***************
*** 3174,3183 ****
    fputs("<body>\n", stdout);
    write_title(FALSE);
    header.write_headings(stdout);
-   fputs("<p>\n", stdout);
    {
      extern const char *version_string;
!     html.begin_comment("Creator:")
         .comment_arg("groff")
         .comment_arg("version")
         .comment_arg(version_string)
--- 3256,3264 ----
    fputs("<body>\n", stdout);
    write_title(FALSE);
    header.write_headings(stdout);
    {
      extern const char *version_string;
!     html.begin_comment("Creator:     ")
         .comment_arg("groff")
         .comment_arg("version")
         .comment_arg(version_string)
***************
*** 3197,3207 ****
    for (font_pointer_list *f = font_list; f; f = f->next) {
      html_font *psf = (html_font *)(f->p);
    }
!   
html.begin_comment("Pages:").comment_arg(itoa(no_of_printed_pages)).end_comment();
    html.end_line();
    html.copy_file(tempfp);
-   putc('\n', stdout);
-   fputs("\n</p>\n", stdout);
    fputs("</body>\n", stdout);
    fputs("</html>\n", stdout);
    fclose(tempfp);
--- 3278,3286 ----
    for (font_pointer_list *f = font_list; f; f = f->next) {
      html_font *psf = (html_font *)(f->p);
    }
!   html.begin_comment("Total number of pages: 
").comment_arg(itoa(no_of_printed_pages)).end_comment();
    html.end_line();
    html.copy_file(tempfp);
    fputs("</body>\n", stdout);
    fputs("</html>\n", stdout);
    fclose(tempfp);
***************
*** 3235,3240 ****
--- 3314,3320 ----
      page_contents->region_words.start_from_head();
      do {
        w = page_contents->region_words.get_data();
+ 
        if ((r->minv == -1) || (w->minv < r->minv)) {
        r->minv = w->minv;
        }
***************
*** 3287,3296 ****
        }
      } else if (strncmp(s, "html:", 5) == 0) {
        int r=font::res;   // resolution of the device actually
!       
!       style sty(0, env->size, env->height, env->slant, env->fontno);
        // need to pass rest of string through to html output during flush
!       page_contents->add_html_command(&sty, &s[5], strlen(s)-5,
                                      env->vpos-env->size*r/72, env->hpos,
                                      env->vpos            , env->hpos);
        // assume that the html command has no width, if it does then we 
hopefully troff
--- 3367,3377 ----
        }
      } else if (strncmp(s, "html:", 5) == 0) {
        int r=font::res;   // resolution of the device actually
! 
!       page_contents->add_html_command(&sbuf_style, &s[5], strlen(s)-5,
! 
        // need to pass rest of string through to html output during flush
! 
                                      env->vpos-env->size*r/72, env->hpos,
                                      env->vpos            , env->hpos);
        // assume that the html command has no width, if it does then we 
hopefully troff
***************
*** 3302,3307 ****
--- 3383,3401 ----
    }
  }
  
+ void set_image_type (char *type)
+ {
+   if (strcmp(type, "gif") == 0) {
+     image_type = gif;
+   } else if (strcmp(type, "png") == 0) {
+     image_type = png;
+     image_device = "png256";
+   } else if (strncmp(type, "png", 3) == 0) {
+     image_type = png;
+     image_device = type;
+   }
+ }
+ 
  // A conforming PostScript document must not have lines longer
  // than 255 characters (excluding line termination characters).
  
***************
*** 3333,3339 ****
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   while ((c = getopt(argc, argv, "F:avdgm?")) != EOF)
      switch(c) {
      case 'v':
        {
--- 3427,3433 ----
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   while ((c = getopt(argc, argv, "F:avdgm?I:r:")) != EOF)
      switch(c) {
      case 'v':
        {
***************
*** 3349,3354 ****
--- 3443,3456 ----
      case 'F':
        font::command_line_font_dir(optarg);
        break;
+     case 'I':
+       // user specifying the type of images we should generate
+       set_image_type(optarg);
+       break;
+     case 'r':
+       // resolution (dots per inch for an image)
+       image_res = atoi(optarg);
+       break;
      case 'd':
        // debugging on
        debug_on = TRUE;
***************
*** 3379,3385 ****
  
  static void usage()
  {
!   fprintf(stderr, "usage: %s [-avdgm?] [-F dir] [files ...]\n",
          program_name);
    exit(1);
  }
--- 3481,3487 ----
  
  static void usage()
  {
!   fprintf(stderr, "usage: %s [-avdgm?] [-r resolution] [-F dir] [-I 
imagetype] [files ...]\n",
          program_name);
    exit(1);
  }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]