 texk/dvipdfm/Makefile.in |    7 +++++--
 texk/dvipdfm/dvipdfm.1   |    3 ++-
 texk/dvipdfm/dvipdfm.c   |   38 ++++++++++++++++++++++++++++++--------
 3 files changed, 37 insertions(+), 11 deletions(-)

Index: tetex-bin-3.0/texk/dvipdfm/Makefile.in
===================================================================
--- tetex-bin-3.0.orig/texk/dvipdfm/Makefile.in	2006-03-02 14:46:40.000000000 +0100
+++ tetex-bin-3.0/texk/dvipdfm/Makefile.in	2006-03-02 16:10:18.000000000 +0100
@@ -12,7 +12,10 @@
 LIBPNGDEP = @LIBPNGDEP@
 LDLIBPNG = @LDLIBPNG@
 
-LD_ALL_LIBS = $(LDLIBPNG) $(LDZLIB)
+#PAPERLIBDEP = "-L /usr/lib"
+LDLIBPAPER = "-lpaper"
+
+LD_ALL_LIBS = $(LDLIBPNG) $(LDZLIB) $(LDLIBPAPER)
 ALL_LIBS_DEP = $(ZLIBDEP) $(LIBPNGDEP)
 
 program = dvipdfm
@@ -29,7 +32,7 @@
 	pngimage.o
 
 $(program): $(objects) $(kpathsea) $(ALL_LIBS_DEP)
-	$(kpathsea_link) $(objects) $(LD_ALL_LIBS) $(LOADLIBES)
+	$(kpathsea_link) $(objects) $(LD_ALL_LIBS) $(LOADLIBES) -lpaper
 
 ebb: $(eobjects) $(kpathsea) $(ALL_LIBS_DEP)
 	$(kpathsea_link) $(eobjects) $(LD_ALL_LIBS) $(LOADLIBES)
Index: tetex-bin-3.0/texk/dvipdfm/dvipdfm.c
===================================================================
--- tetex-bin-3.0.orig/texk/dvipdfm/dvipdfm.c	2006-03-02 14:46:40.000000000 +0100
+++ tetex-bin-3.0/texk/dvipdfm/dvipdfm.c	2006-03-02 16:10:18.000000000 +0100
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <limits.h>
 #include <ctype.h>
+#include <paper.h>
 #include "config.h"
 #include "system.h"
 #include "mem.h"
@@ -62,23 +63,35 @@
   {"legal" , { 612.0, 1008.0}},
   {"ledger" , { 1224.0, 792.0}},
   {"tabloid" , { 792.0, 1224.0}},
+  {"a6" , { 297.64, 420.91}},
   {"a5" , { 420.91, 595.27}},
   {"a4" , { 595.27, 841.82}},
-  {"a3" , { 841.82, 1190.16}}};
+  {"a3" , { 841.82, 1190.16}},
+  {"b6" , { 364.25, 515.91}},
+  {"b5" , { 515.91, 728.50}},
+  {"b4" , { 728.50, 1031.81}},
+  {"b3" , { 1031.81, 1457.00}},
+  {"b5var" , { 515.91, 651.97}}};
 
-static rect get_paper_size (char *string)
+static rect get_paper_size (char *string, int error_flag)
 {
+  rect nullpaper = { 0.0, 0.0 };
   int i;
+  if (string == NULL || string[0] == '\0')
+    return nullpaper;
   for (i=0; i<sizeof(paper_sizes)/sizeof(paper_sizes[0]); i++) {
     if (!strcmp (string, paper_sizes[i].s))
       break;
   }
   if (i == sizeof(paper_sizes)/sizeof(paper_sizes[0]))
+  { if (!error_flag)
+    return nullpaper;
+  else
     ERROR ("Paper size is invalid");
+  }
   return paper_sizes[i].data;
 }
 
-
 char *dvi_filename = NULL, *pdf_filename = NULL;
 static void set_default_pdf_filename(void)
 {
@@ -113,7 +126,8 @@
    fprintf (stdout, "-l \t\tLandscape mode\n");
    fprintf (stdout, "-m number\tSet additional magnification\n");
    fprintf (stdout, "-p papersize\tSet papersize (letter, legal,\n");
-   fprintf (stdout, "            \tledger, tabloid, a4, or a3) [letter]\n");
+   fprintf (stdout, "            \tledger, tabloid, a6, a5, a4, a3,\n");
+   fprintf (stdout, "            \tb6, b5, b4, b3, or b5var) [letter]\n");
    fprintf (stdout, "-r resolution\tSet resolution (in DPI) for raster fonts [600]\n");
    fprintf (stdout, "-s pages\tSelect page ranges (-)\n");
    fprintf (stdout, "-t      \tEmbed thumbnail images\n");
@@ -367,7 +381,7 @@
 	  struct rect paper_size;
 	  if (argc < 2)
 	    ERROR ("Missing paper size");
-	  paper_size = get_paper_size (argv[1]);
+	  paper_size = get_paper_size (argv[1], 1);
 	  paper_width = paper_size.width;
 	  paper_height = paper_size.height;
 	  pop_arg();
@@ -507,8 +521,7 @@
   psimage_close();
 }
 
-static char *config_file_name = "config";
-static void read_config_file (void)
+static void read_config_file (char *config_file_name)
 {
   char *full_config_name, *start, *end;
   char *argv[2], *option;
@@ -578,8 +591,17 @@
   argv+=1;
   argc-=1;
 
+  {
+    rect paper_size = get_paper_size (systempapername (), 0);
+    if (paper_size.width != 0) {
+      paper_width = paper_size.width;
+      paper_height = paper_size.height;
+    }
+  }
   /* Process config file, if any */
-  read_config_file();
+  /* yes, in Debian there are two: config and an additional fontmaps file */
+  read_config_file("config");
+  read_config_file("fontmaps");
 
   do_args (argc, argv);
 
Index: tetex-bin-3.0/texk/dvipdfm/dvipdfm.1
===================================================================
--- tetex-bin-3.0.orig/texk/dvipdfm/dvipdfm.1	2006-03-02 14:46:40.000000000 +0100
+++ tetex-bin-3.0/texk/dvipdfm/dvipdfm.1	2006-03-02 16:10:18.000000000 +0100
@@ -139,7 +139,8 @@
 .TP 5
 .B \-\^p " paper"
 Select the papersize by name (e.g.,
-.BR letter ", " legal ", " ledger ", " tabloid ", " a3 ", " a4 ", or " a5
+.BR letter ", " legal ", " ledger ", " tabloid ", " a3 ", " a4 ", "
+.BR a5 ", " a6 ", " b3 ", " b4 ", " b5 ", " b6 ", or " b5var
 )
 
 .TP 5
