diff options
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | font/devhtml/DESC.proto | 2 | ||||
-rw-r--r-- | font/devhtml/Makefile.sub | 2 | ||||
-rw-r--r-- | man/groff_font.man | 21 | ||||
-rw-r--r-- | src/include/font.h | 3 | ||||
-rw-r--r-- | src/libs/libgroff/font.cpp | 21 | ||||
-rw-r--r-- | src/libs/libgroff/fontfile.cpp | 2 | ||||
-rw-r--r-- | src/preproc/html/pre-html.cpp | 11 |
8 files changed, 82 insertions, 7 deletions
@@ -1,3 +1,30 @@ +2004-10-05 Gaius Mulley <gaius@glam.ac.uk> + + * src/include/font.h (font): New member function + `get_image_generator'. + New variables `unscaled_charwidths' and `image_generator'. + + * src/libs/libgroff/font.cpp (font::get_width): Always return the + character's unscaled width if `font::unscaled_charwidths' is set. + (font::get_image_generator): New function. + (font::load_desc): Check the `unscaled_charwidths' and + `image_generator' keywords. + + * src/libs/libgroff/fontfile.cpp: Initialize + `font::unscaled_charwidths' and `font::image_generator'. + + * font/devhtml/DESC.proto: s/html/unscaled_charwidths/. + + * font/devhtml/Makefile.sub (DESC): Set `image_generator' keyword. + + * man/groff_font.man: Document `unscaled_charwidths' and + `image_generator'. + + * src/preproc/html/pre-html.cpp: Include `device.h'. + (image_gen): New global variable. + (imageList::createPage): Use `image_gen'. + (main): Use `image_generator' keyword. + 2004-10-04 Gaius Mulley <gaius@glam.ac.uk> * tmac/html.tmac: Handle \[sqrtex]. diff --git a/font/devhtml/DESC.proto b/font/devhtml/DESC.proto index 9a2fbe57..db407f7b 100644 --- a/font/devhtml/DESC.proto +++ b/font/devhtml/DESC.proto @@ -5,7 +5,7 @@ unitwidth 10 sizes 1-1000 0 fonts 9 R I B BI CR CI CB CBI S tcommand -html +unscaled_charwidths postpro post-grohtml prepro pre-grohtml use_charnames_in_special diff --git a/font/devhtml/Makefile.sub b/font/devhtml/Makefile.sub index 8afe0376..474c0f28 100644 --- a/font/devhtml/Makefile.sub +++ b/font/devhtml/Makefile.sub @@ -31,4 +31,4 @@ DESC: DESC.proto -e "s/^vert .*$$/vert `expr $(RES) / $(LPI)`/" \ -e "s/^fonts .*$$/fonts `set $(FONTS); echo $$#` $(FONTS)/" \ $(srcdir)/DESC.proto >$@ - + @echo "image_generator $(GHOSTSCRIPT)" >> $@ diff --git a/man/groff_font.man b/man/groff_font.man index 7da71550..b806aac9 100644 --- a/man/groff_font.man +++ b/man/groff_font.man @@ -48,7 +48,8 @@ font format. The font files for device .I name are stored in a directory -.BI dev name. +.BI dev name\c +\&. . There are two types of file: a device description file called @@ -103,6 +104,17 @@ The horizontal resolution is machine units. . .TP +.BI image_generator\ string +Needed for +.B grohtml +only. +It specifies the program to generate PNG images from +PostScript input. +Under GNU/Linux this is usually +.I gs +but under other systems (notably cygwin) it might be set to another name. +. +.TP .BI paperlength\ n The physical vertical dimension of the output medium in machine units. . @@ -276,6 +288,13 @@ for fonts whose point size is scaled points. . .TP +.B unscaled_charwidths +Make the font handling module always return unscaled character widths. +Needed for the +.B grohtml +device. +. +.TP .B use_charnames_in_special This command indicates that troff should encode named characters inside special commands. diff --git a/src/include/font.h b/src/include/font.h index 987cf6cc..856bcd7b 100644 --- a/src/include/font.h +++ b/src/include/font.h @@ -54,6 +54,7 @@ public: const char *get_special_device_encoding(int index); const char *get_name(); const char *get_internal_name(); + const char *get_image_generator(); static int scan_papersize(const char *, const char **, double *, double *); @@ -77,8 +78,10 @@ public: static int spare2; static int sizescale; static int tcommand; + static int unscaled_charwidths; static int pass_filenames; static int use_charnames_in_special; + static const char *image_generator; static const char **font_name_table; static const char **style_table; diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp index 6af6c30b..6f7a83a3 100644 --- a/src/libs/libgroff/font.cpp +++ b/src/libs/libgroff/font.cpp @@ -274,7 +274,7 @@ int font::get_width(int c, int point_size) int i = ch_index[c]; assert(i >= 0); - if (point_size == unitwidth) + if (point_size == unitwidth || font::unscaled_charwidths) return ch[i].width; if (!widths_cache) @@ -396,7 +396,12 @@ const char *font::get_internal_name() const char *font::get_special_device_encoding(int c) { assert(c >= 0 && c < nindices && ch_index[c] >= 0); - return( ch[ch_index[c]].special_device_coding ); + return ch[ch_index[c]].special_device_coding; +} + +const char *font::get_image_generator() +{ + return image_generator; } void font::alloc_ch_index(int idx) @@ -815,7 +820,7 @@ static struct { { "spare1", &font::biggestfont }, { "biggestfont", &font::biggestfont }, { "spare2", &font::spare2 }, - { "sizescale", &font::sizescale } + { "sizescale", &font::sizescale }, }; int font::load_desc() @@ -910,6 +915,8 @@ int font::load_desc() return 0; } } + else if (strcmp("unscaled_charwidths", p) == 0) + unscaled_charwidths = 1; else if (strcmp("pass_filenames", p) == 0) pass_filenames = 1; else if (strcmp("sizes", p) == 0) { @@ -986,6 +993,14 @@ int font::load_desc() tcommand = 1; else if (strcmp("use_charnames_in_special", p) == 0) use_charnames_in_special = 1; + else if (strcmp("image_generator", p) == 0) { + p = strtok(0, WS); + if (!p) { + t.error("image_generator command requires an argument"); + return 0; + } + image_generator = strdup(p); + } else if (strcmp("charset", p) == 0) break; else if (unknown_desc_command_handler) { diff --git a/src/libs/libgroff/fontfile.cpp b/src/libs/libgroff/fontfile.cpp index 0f245518..5dc9fd60 100644 --- a/src/libs/libgroff/fontfile.cpp +++ b/src/libs/libgroff/fontfile.cpp @@ -45,7 +45,9 @@ int font::spare2 = 0; int font::sizescale = 1; int font::tcommand = 0; int font::pass_filenames = 0; +int font::unscaled_charwidths = 0; int font::use_charnames_in_special = 0; +const char *font::image_generator = NULL; const char **font::font_name_table = 0; int *font::sizes = 0; const char *font::family = 0; diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp index 8abcb84c..d0375ee7 100644 --- a/src/preproc/html/pre-html.cpp +++ b/src/preproc/html/pre-html.cpp @@ -34,6 +34,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "defs.h" #include "searchpath.h" #include "paper.h" +#include "device.h" #include "font.h" #include <errno.h> @@ -210,6 +211,7 @@ static char *htmlFileName = NULL; // output of pre-html output which static char *linebuf = NULL; // for scanning devps/DESC static int linebufsize = 0; +static const char *image_gen = NULL; // the `gs' program const char *const FONT_ENV_VAR = "GROFF_FONT_PATH"; static search_path font_path(FONT_ENV_VAR, FONTPATH, 0, 0); @@ -926,11 +928,12 @@ int imageList::createPage(int pageno) html_system(s, 1); s = make_message("echo showpage | " - "gs%s -q -dBATCH -dSAFER " + "%s%s -q -dBATCH -dSAFER " "-dDEVICEHEIGHTPOINTS=792 " "-dDEVICEWIDTHPOINTS=%d -dFIXEDMEDIA=true " "-sDEVICE=%s -r%d %s " "-sOutputFile=%s %s -\n", + image_gen, EXE_EXT, (getMaxX(pageno) * image_res) / postscriptRes, image_device, @@ -1701,6 +1704,12 @@ int main(int argc, char **argv) } exit(1); #endif /* CAPTURE_MODE */ + device = "html"; + if (!font::load_desc()) + fatal("cannot find devhtml/DESC exiting"); + image_gen = font::image_generator; + if (image_gen == NULL || (strcmp(image_gen, "") == 0)) + fatal("devhtml/DESC must set the image_generator field, exiting"); postscriptRes = get_resolution(); i = scanArguments(argc, argv); setupAntiAlias(); |