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

[orca-users:06711] ORCA版MONPE 0.6.2 のパッチ



島谷@恵庭です.

時々安価なPSプリンタでの印刷速度が話題になってますが,
私もBorother 5070DN を買い,ORCAでレセプトを印刷してみた所,
2,3 ppm という驚異的な!?スピードにびっくりしました.

そこで,MONPEのPostscript出力のあたりをいじってみたところ,
だいたい9,10 ppm で印刷できるようになりましたので,
パッチを公開します.

パッチファイルは最後にのせますので,コピー&ペーストで
お試し下さい.
レセ,処方せん,日計表でテストしてみましたが,問題ないようです.

あくまで自己責任でお願いします.

[準備]
/etc/apt/sources.list に,
deb-src ftp://ftp.orca.med.or.jp/pub/debian woody jma
を追加.

開発に必要な,*-dev を,apt-get install
幾つか必要だったのですが,忘れました.
ちなみに,下に私の所で,dpkg -l *-dev した結果をのせます.

ii  autotools-dev
ii  dpkg-dev
ii  gdk-imlib-dev
ii  libart-dev
ii  libaudiofile-dev
ii  libc6-dev
ii  libdb3-dev
ii  libesd0-dev
ii  libfixed-dev
ii  libglib1.2-dev
ii  libgnome-dev
ii  libgnorba-dev
ii  libgtk1.2-dev
ii  libjpeg62-dev
ii  liborbit-dev
ii  libpng2-dev
ii  libpopt-dev
ii  libstdc++2.10-dev
ii  libtiff3g-dev
ii  libungif4-dev
ii  libwrap0-dev
ii  libxml-dev
ii  manpages-dev
ii  xlibs-dev
ii  zlib1g-dev

[MONPEのソースのインストール]
ホームディレクトリでいいと思います.

#apt-get source monpe

これで,~/monpe-0.6.2 以下にインストールされます.

[パッチあて]
( 下の,"diff -ur monpe-0.6.2/app/paginate_psprint.c
monpe-0.6.2b/app/paginate_psprint.c" 以下をコピーして
hogehoge.diff というようなファイルをつくっておく.)

#cd monpe-0.6.2/app
#patch < diffファイル

このあと,

#cd ~/monpe-0.6.2
#./configure
#make
#make install

で,おそらく,/usr/local/bin にパッチのあたったmonpeができてます.

オリジナルの,/usr/bin/monpe と,/usr/bin/monpe-print を
バックアップしてから,
/usr/bin にパッチのあたったmonpeとmonpe-printをコピーします.

これでおしまい...

半角全角が混在した文字列の扱いを少しいじったので,
見た感じが少し違うかもしれません.
また,Courier 以外のフォントを指定した時の
中央そろえ,右そろえがうまくいくようになったようです.

ではでは...

diff -ur monpe-0.6.2/app/paginate_psprint.c
monpe-0.6.2b/app/paginate_psprint.c
--- monpe-0.6.2/app/paginate_psprint.c	Wed Nov 19 14:26:46 2003
+++ monpe-0.6.2b/app/paginate_psprint.c	Tue Jun 15 17:13:12 2004
@@ -92,14 +92,11 @@

   /* transform coordinate system */
   if (data->paper.is_portrait) {
-    fprintf(rend->file, "%f %f scale\n", 28.346457*scale,
-28.346457*scale);
-    fprintf(rend->file, "%f %f translate\n", lmargin/scale - bounds->left,
-	    -bmargin/scale - bounds->bottom);
+    fprintf(rend->file, "%f %f scale\n", 28.346457*scale, 28.346457*scale);
   } else {
     fprintf(rend->file, "90 rotate\n");
-    fprintf(rend->file, "%f %f scale\n", 28.346457*scale,
-28.346457*scale);
-    fprintf(rend->file, "%f %f translate\n", lmargin/scale - bounds->left,
-	    tmargin/scale - bounds->top);
+    fprintf(rend->file, "%f %f scale\n", 28.346457*scale, 28.346457*scale);
+    fprintf(rend->file, "0.0 %f translate\n", -bounds->bottom );
   }

   /* set up clip mask */
diff -ur monpe-0.6.2/app/render_eps.c monpe-0.6.2b/app/render_eps.c
--- monpe-0.6.2/app/render_eps.c	Wed Nov 19 14:26:47 2003
+++ monpe-0.6.2b/app/render_eps.c	Tue Jun 15 18:08:42 2004
@@ -152,7 +152,7 @@
 	    "    /%s findfont\n"
 	    "    dup length dict begin\n"
 	    "	{1 index /FID ne {def} {pop pop} ifelse} forall\n"
-	    "	/Encoding isolatin1encoding def\n"
+	    "	/Encoding ISOLatin1Encoding def\n"
 	    "    currentdict end\n"
 	    "definefont pop\n", fontname, fontname);
 }
@@ -218,34 +218,6 @@
 	  (int) ceil((extent->right - extent->left)*scale),
 	  (int) ceil((extent->bottom - extent->top)*scale) );

-  fprintf(file,
-	  "[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar
/percent /ampersand /quoteright\n"
-	  "/parenleft /parenright /asterisk /plus /comma /hyphen /period
/slash /zero /one\n"
-	  "/two /three /four /five /six /seven /eight /nine /colon /semicolon\n"
-	  "/less /equal /greater /question /at /A /B /C /D /E\n"
-	  "/F /G /H /I /J /K /L /M /N /O\n"
-	  "/P /Q /R /S /T /U /V /W /X /Y\n"
-	  "/Z /bracketleft /backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c\n"
-	  "/d /e /f /g /h /i /j /k /l /m\n"
-	  "/n /o /p /q /r /s /t /u /v /w\n"
-	  "/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef
/.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/space /exclamdown /cent /sterling /currency /yen /brokenbar
/section /dieresis /copyright\n"
-	  "/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior\n"
-	  "/acute /mu /paragraph /periodcentered /cedilla /onesuperior
/ordmasculine /guillemotright /onequarter /onehalf\n"
-	  "/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla\n"
-	  "/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute
/Icircumflex /Idieresis /Eth /Ntilde\n"
-	  "/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash
/Ugrave /Uacute /Ucircumflex\n"
-	  "/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex
/atilde /adieresis /aring\n"
-	  "/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave
/iacute /icircumflex /idieresis\n"
-	  "/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis
/divide /oslash /ugrave\n"
-	  "/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis]
/isolatin1encoding exch def\n");
-
   print_reencode_font(file, "Times-Roman");
   print_reencode_font(file, "Times-Italic");
   print_reencode_font(file, "Times-Bold");
@@ -294,8 +266,8 @@
 	  "/gs {gsave} bind def\n"
 	  "/sa {save} bind def\n"
 	  "/rs {restore} bind def\n"
-	  "/l {lineto} bind def\n"
-	  "/m {moveto} bind def\n"
+	  "/l {%f exch sub lineto} bind def\n"
+	  "/m {%f exch sub moveto} bind def\n"
 	  "/rm {rmoveto} bind def\n"
 	  "/n {newpath} bind def\n"
 	  "/s {stroke} bind def\n"
@@ -324,7 +296,7 @@
           "   /y exch def\n"
           "   /x exch def"
 	  "   /savematrix mtrx currentmatrix def\n"
-          "   x y tr xrad yrad sc\n"
+          "   x y %f exch sub tr xrad yrad sc\n"
           "   0 0 1 startangle endangle arc\n"
           "   savematrix setmatrix\n"
           "   end\n"
@@ -377,10 +349,9 @@
 	  */
 	
 	  "%f %f scale\n"
-	  "%f %f translate\n"
 	  "%%%%EndProlog\n\n\n",
-	  scale, -scale,
-	  -extent->left, -extent->bottom );
+	  extent->bottom, extent->bottom, extent->bottom,
+	  scale, scale );

   return renderer;
 }
@@ -448,34 +419,6 @@
 	  dia->data->paper.is_portrait ? "Portrait" : "Landscape");

   fprintf(file, "%%%%BeginProlog\n");
-  fprintf(file,
-	  "[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar
/percent /ampersand /quoteright\n"
-	  "/parenleft /parenright /asterisk /plus /comma /hyphen /period
/slash /zero /one\n"
-	  "/two /three /four /five /six /seven /eight /nine /colon /semicolon\n"
-	  "/less /equal /greater /question /at /A /B /C /D /E\n"
-	  "/F /G /H /I /J /K /L /M /N /O\n"
-	  "/P /Q /R /S /T /U /V /W /X /Y\n"
-	  "/Z /bracketleft /backslash /bracketright /asciicircum /underscore
/quoteleft /a /b /c\n"
-	  "/d /e /f /g /h /i /j /k /l /m\n"
-	  "/n /o /p /q /r /s /t /u /v /w\n"
-	  "/x /y /z /braceleft /bar /braceright /asciitilde /.notdef /.notdef
/.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef\n"
-	  "/space /exclamdown /cent /sterling /currency /yen /brokenbar
/section /dieresis /copyright\n"
-	  "/ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior\n"
-	  "/acute /mu /paragraph /periodcentered /cedilla /onesuperior
/ordmasculine /guillemotright /onequarter /onehalf\n"
-	  "/threequarters /questiondown /Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla\n"
-	  "/Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute
/Icircumflex /Idieresis /Eth /Ntilde\n"
-	  "/Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash
/Ugrave /Uacute /Ucircumflex\n"
-	  "/Udieresis /Yacute /Thorn /germandbls /agrave /aacute /acircumflex
/atilde /adieresis /aring\n"
-	  "/ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave
/iacute /icircumflex /idieresis\n"
-	  "/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis
/divide /oslash /ugrave\n"
-	  "/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis]
/isolatin1encoding exch def\n");
-
   print_reencode_font(file, "Times-Roman");
   print_reencode_font(file, "Times-Italic");
   print_reencode_font(file, "Times-Bold");
@@ -524,8 +467,8 @@
 	  "/gs {gsave} bind def\n"
 	  "/sa {save} bind def\n"
 	  "/rs {restore} bind def\n"
-	  "/l {lineto} bind def\n"
-	  "/m {moveto} bind def\n"
+	  "/l {%f exch sub lineto} bind def\n"
+	  "/m {%f exch sub moveto} bind def\n"
 	  "/rm {rmoveto} bind def\n"
 	  "/n {newpath} bind def\n"
 	  "/s {stroke} bind def\n"
@@ -554,7 +497,7 @@
           "   /y exch def\n"
           "   /x exch def"
 	  "   /savematrix mtrx currentmatrix def\n"
-          "   x y tr xrad yrad sc\n"
+          "   x y %f exch sub tr xrad yrad sc\n"
           "   0 0 1 startangle endangle arc\n"
           "   savematrix setmatrix\n"
           "   end\n"
@@ -606,19 +549,130 @@
 	    "} bind def\n\n"
 	  */
 	
-	  "%%%%EndProlog\n\n\n");
+	  "%%%%EndProlog\n\n\n", dia->data->paper.height,
dia->data->paper.height, dia->data->paper.height );

   return renderer;
 }

+#include "text.h"
+
+GList* string_list = NULL;
+char  last_font[256];
+real  last_height;
+Color last_color;
+
+typedef struct _StringListData StringListData;
+struct _StringListData {
+  char* fontname;
+  char* data;
+
+  real      height;
+  Point     pos;
+  Alignment alignment;
+  Color     color;
+};
+
+StringListData*
+new_string_list_data( const char* buf, gboolean is_kanji, const char*
font, real height, Point* pos, Alignment alignment, Color* color )
+{
+  StringListData* data;
+  data = g_new( StringListData, 1 );
+
+  data->fontname = g_malloc( strlen( font ) + 8 );
+  strcpy( data->fontname, font );
+
+  if ( is_kanji )
+    strcat( data->fontname, "-RKSJ-H" );
+
+  data->data = g_malloc( strlen( buf ) + 1 );
+  strcpy( data->data, buf );
+
+  data->height = height;
+  data->pos = *pos;
+  data->alignment = alignment;
+  data->color = *color;
+
+  return data;
+}
+
+void
+delete_string_list_data( StringListData* data)
+{
+  g_free( data->fontname );
+  g_free( data->data );
+}
+
+void
+show_string_list_data( gpointer data, gpointer user_data )
+{
+  StringListData* p;
+  RendererEPS* renderer;
+
+  p = (StringListData*)data;
+  renderer = (RendererEPS*)user_data;
+
+  if ( p->height != last_height || strcmp( p->fontname, last_font ) !=
0 ) {
+    last_height = p->height;
+    strcpy( last_font, p->fontname );
+    fprintf( renderer->file, "/%s ff %f scf sf\n", p->fontname,
p->height );
+  }
+
+  if ( ( p->color.red   != last_color.red )   ||
+       ( p->color.green != last_color.green ) ||
+       ( p->color.blue  != last_color.blue ) )
+  {
+    last_color = p->color;
+    fprintf( renderer->file, "%f %f %f srgb\n", p->color.red,
p->color.green, p->color.blue);
+  }
+
+  fprintf( renderer->file, "(%s) ", p->data );
+
+  switch ( p->alignment ) {
+  case ALIGN_LEFT:
+    fprintf( renderer->file, "%f %f m sh\n", p->pos.x, p->pos.y );
+    break;
+  case ALIGN_CENTER:
+    fprintf( renderer->file, "dup sw 2 div %f ex sub %f m sh\n",
p->pos.x, p->pos.y );
+    break;
+  case ALIGN_RIGHT:
+    fprintf( renderer->file, "dup sw %f ex sub %f m sh\n", p->pos.x,
p->pos.y );
+    break;
+  }
+}
+
+gint
+sort( gconstpointer a, gconstpointer b )
+{
+  StringListData *pa, *pb;
+  pa = (StringListData*)a;
+  pb = (StringListData*)b;
+
+  if ( strcmp( pa->fontname, pb->fontname ) == 0 ) {
+    if ( pa->height > pb->height )
+      return 1;
+    else if ( pa->height == pb->height )
+      return 0;
+    else
+      return -1;
+  }
+
+  return strcmp( pa->fontname, pb->fontname );
+}
+
 static void
 begin_render(RendererEPS *renderer, DiagramData *data)
 {
+  *last_font = 0;
+  last_height = 0;
 }

 static void
 end_render(RendererEPS *renderer)
 {
+  g_list_foreach( string_list, show_string_list_data, renderer );
+  g_list_foreach( string_list, (GFunc)delete_string_list_data, NULL );
+  g_list_free( string_list );
+  string_list = NULL;
   if (!renderer->is_ps) {
     fprintf(renderer->file, "showpage\n");
     fclose(renderer->file);
@@ -1048,7 +1102,7 @@
     break;
   }

-  fprintf(renderer->file, " gs 1 -1 sc sh gr\n");
+  fprintf(renderer->file, " sh\n");
 }

 #ifdef JAPANESE
@@ -1066,6 +1120,13 @@
   int i;
   int s;
   char *buff;
+
+  StringListData* listed_text;
+  char* font;
+  const char *str;
+  int len;
+  gboolean is_kanji;
+  int j;

   _pos = *pos;

@@ -1090,6 +1151,68 @@
     }
     if (is_space) return;
   }
+
+  font =font_get_psfontname( renderer->font)[0];
+  is_kanji = FALSE;
+
+  /* EUC->shiftJIS, Escape '(', ')', '\' */
+  buff = g_malloc( strlen( text ) * 2 + 1 );
+  *buff = 0;
+  for ( i = 0, j = 0; i < strlen( text ); i++, j++  )
+  {
+    unsigned char c1, c2;
+    c1 = text[i];
+
+    if ( c1 > 0x7F )
+    {
+      if ( text[i+1] == 0 ) break;
+
+      is_kanji = TRUE;
+      c1 &= 0x7F;
+      c2 = text[i+1];
+      c2 &= 0x7F;
+
+      c1 -= 0x21;
+
+      if ( c1 & 1 )
+        c2 += 0x7E;
+      else
+      {
+        c2 += 0x1F;
+        if ( c2 > 0x7E )
+          c2++;
+      }
+
+      c1 >>= 1;
+      if ( c1 < 0x1F )
+        c1 += 0x81;
+      else
+        c1 += 0xC1;
+
+      buff[j] = c1;
+      c1 = c2;
+      j++;
+      i++;
+    }
+
+    if ( strchr( "()\\", c1 ) != 0 )
+    {
+      buff[j] = '\\';
+      j++;
+    }
+
+    buff[j] = c1;
+  }
+  if ( is_kanji )
+    font =font_get_psfontname( renderer->font)[1];
+  buff[j] = 0;
+  listed_text = new_string_list_data( buff, is_kanji,
+                                      font,
+                                      renderer->font_height,
+                                      pos, alignment, color );
+  string_list = g_list_insert_sorted( string_list, listed_text, sort );
+  g_free( buff );
+  return;

   if (dia_no_x_display && ((single > 0) || (multi > 0))) {
     gint len, sn; /* single char num */