Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
e2ps-4.34修正パッチ(ページ数カウント誤りの修正、EPS記述の除去、用紙サイズ修正)
diff -urN e2ps-4.34.orig/e2ps.c e2ps-4.34/e2ps.c
--- e2ps-4.34.orig/e2ps.c 2002-08-21 17:50:02.000000000 +0900
+++ e2ps-4.34/e2ps.c 2017-06-05 01:05:59.816733000 +0900
@@ -22,6 +22,7 @@
char *gsBoldAsciiFont = NULL, *gsBoldItalicAsciiFont = NULL;
char *gsBoldKanjiFont = NULL, *gsBoldItalicKanjiFont = NULL;
int giWidth, giHeight;
+int paWidth, paHeight;
int giPage, giPsPage;
uchar guStyle;
uchar guBox;
@@ -131,7 +132,9 @@
giMaxLine = MAXLINE;
strcpy(sPaper, "A4");
giWidth = A4WIDTH;
+ paWidth = A4WIDTH;
giHeight = A4HEIGHT;
+ paHeight = A4HEIGHT;
gfFontSize = FONTSIZE;
gfTopMargin = TOP;
gfBottomMargin = BOTTOM;
@@ -328,18 +331,24 @@
strcpy(sPaper, "A4");
giWidth = A4WIDTH;
giHeight = A4HEIGHT;
+ paWidth = A4WIDTH;
+ paHeight = A4HEIGHT;
}
else if ( strcmp(argv[i], "-b4") == 0 ) {
/* B4 */
strcpy(sPaper, "B4");
giWidth = B4WIDTH;
giHeight = B4HEIGHT;
+ paWidth = B4WIDTH;
+ paHeight = B4HEIGHT;
}
else if ( strcmp(argv[i], "-le") == 0 ) {
/* Letter */
strcpy(sPaper, "LETTER");
giWidth = LEWIDTH;
giHeight = LEHEIGHT;
+ paWidth = LEWIDTH;
+ paHeight = LEHEIGHT;
}
else if ( strcmp(argv[i], "-tm") == 0 ) {
/* Top margin */
@@ -630,7 +639,7 @@
/* Start Input and Output */
/* Header */
- fprintf(gpfOut, "%%!PS-Adobe-2.0 EPSF-1.2\n");
+ fprintf(gpfOut, "%%!PS-Adobe-2.0\n");
fprintf(gpfOut, "%%%%Title:");
for ( iFileNum = 0 ; iFileNum < iFiles ; iFileNum++ ) {
fprintf(gpfOut, " %s", sFileNames[iFileNum]);
@@ -642,6 +651,7 @@
fprintf(gpfOut, "%%%%PageOrder: Ascend\n");
fprintf(gpfOut, "%%%%DocumentPaperSizes: %s\n", sPaper);
fprintf(gpfOut, "%%%%Orientation: Portrait\n");
+ fprintf(gpfOut, "%%%%DocumentMedia: %s %d %d 0 () () \n", sPaper, paWidth, paHeight);
#ifdef TEKTRO
/* Number of paper */
fprintf(gpfOut, "%%%%Requirements: numcopies(%d) collate\n", uCopy);
@@ -660,6 +670,9 @@
}
#endif
+ /* Set %%BeginSetup */
+ fprintf(gpfOut, "\n%%%%BeginSetup\n");
+
/* Set Fonts */
fprintf(gpfOut, "/A-R { /%s findfont %.2f scalefont [1 0 0 1 0 0.12] makefont setfont } bind def\n", gsAsciiFont, gfFontSize);
fprintf(gpfOut, "/A-B { /%s findfont %.2f scalefont [1 0 0 1 0 0.12] makefont setfont } bind def\n", gsBoldAsciiFont, gfFontSize);
@@ -730,6 +743,9 @@
}
fprintf(gpfOut, "\n\n");
+ /* Set %%EndSetup */
+ fprintf(gpfOut, "%%%%EndSetup\n\n");
+
/* Page */
giPsPage = 0;
@@ -917,7 +933,7 @@
free(sFileData);
}
/* Finish */
- fprintf(gpfOut, "%%%%Trailer\n");
+ fprintf(gpfOut, "%%%%Trailer\n\n%%%%EOF\n");
if ( uLpr ) {
pclose(gpfOut);
@@ -931,7 +947,7 @@
fprintf(stderr, "%% %d ¥Ú¡¼¥¸½ÐÎϤ·¤Þ¤·¤¿\n", giPsPage);
}
else {
- if ( giPsPage == 1 ) {
+ if ( giPsPage != 1 ) {
fprintf(stderr, "%% %d pages were outputed.\n", giPsPage);
}
else {
diff -urN e2ps-4.34.orig/e2ps.h e2ps-4.34/e2ps.h
--- e2ps-4.34.orig/e2ps.h 2002-08-21 17:50:05.000000000 +0900
+++ e2ps-4.34/e2ps.h 2017-06-05 01:05:59.817353000 +0900
@@ -31,12 +31,12 @@
#define ESC (0x1b) /* Escape */
/* Paper */
-#define A4WIDTH (594)
-#define A4HEIGHT (840)
+#define A4WIDTH (595)
+#define A4HEIGHT (842)
#define LEWIDTH (612)
-#define LEHEIGHT (796)
-#define B4WIDTH (730)
-#define B4HEIGHT (1030)
+#define LEHEIGHT (792)
+#define B4WIDTH (709)
+#define B4HEIGHT (1001)
/* sqrt(0.5) */
#define SQRT (0.707106781186548)
diff -urN e2ps-4.34.orig/ps-font.c e2ps-4.34/ps-font.c
--- e2ps-4.34.orig/ps-font.c 2002-02-05 00:25:38.000000000 +0900
+++ e2ps-4.34/ps-font.c 2017-06-05 01:04:20.312674000 +0900
@@ -11,45 +11,45 @@
#include "e2ps.h"
-char *gsFonts = "Times-Roman
-Times-Italic
-Times-Bold
-Times-BoldItalic
-Helvetica
-Helvetica-Oblique
-Helvetica-Bold
-Helvetica-BoldOblique
-Courier
-Courier-Oblique
-Courier-Bold
-Courier-BoldOblique
-Symbol
-AvantGarde-Book
-AvantGarde_BookOblique
-AvantGarde_Demi
-AvantGarde_DemiOblique
-Bookman-Light
-Bookman-LightItalic
-Bookman-Demi
-Bookman-DemiItalic
-Helvetica-Narrow
-Helvetica-Narrow-Oblique
-Helvetica-Narrow-Bold
-Helvetica-Narrow-BoldObliqeu
-NewCenturySchlbl-Roman
-NewCenturySchlbl-Italic
-NewCenturySchlbl-Bold
-NewCenturySchlbl-BoldItalic
-Palatino-Roman
-Palatino-Italic
-Palatino-Bold
-Palatino-BoldItalic
-Zapfchancery-MediumItalic
-ZapfDingbats
-Ryumin-Light.Hiragana
-Ryumin-Light.Katakana
-Gothic-Meduim.Hiragana
-Gothic-Medium.Katakana
+char *gsFonts = "Times-Roman\
+Times-Italic\
+Times-Bold\
+Times-BoldItalic\
+Helvetica\
+Helvetica-Oblique\
+Helvetica-Bold\
+Helvetica-BoldOblique\
+Courier\
+Courier-Oblique\
+Courier-Bold\
+Courier-BoldOblique\
+Symbol\
+AvantGarde-Book\
+AvantGarde_BookOblique\
+AvantGarde_Demi\
+AvantGarde_DemiOblique\
+Bookman-Light\
+Bookman-LightItalic\
+Bookman-Demi\
+Bookman-DemiItalic\
+Helvetica-Narrow\
+Helvetica-Narrow-Oblique\
+Helvetica-Narrow-Bold\
+Helvetica-Narrow-BoldObliqeu\
+NewCenturySchlbl-Roman\
+NewCenturySchlbl-Italic\
+NewCenturySchlbl-Bold\
+NewCenturySchlbl-BoldItalic\
+Palatino-Roman\
+Palatino-Italic\
+Palatino-Bold\
+Palatino-BoldItalic\
+Zapfchancery-MediumItalic\
+ZapfDingbats\
+Ryumin-Light.Hiragana\
+Ryumin-Light.Katakana\
+Gothic-Meduim.Hiragana\
+Gothic-Medium.Katakana\
";
Owner

taraijpn commented May 31, 2017 edited

この patch は自由にお使いいただければ幸いです。

Owner

taraijpn commented Jun 4, 2017 edited

内容更新。patchに含まれていた EUC-JP のメッセージを UTF-8 でコピペしてしまっていた。diffには含まれないところなので大丈夫だとは思うけど、念のため。
(日本語を含むpatchをコピペでgistに貼ってはいけない orz )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment