Takanori Oshiro
unread,Apr 15, 2023, 8:45:31 PM4/15/23You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
日本語EUCを含んだ文書をポストスクリプト言語に変換するフィルターです
自分で使うためエラーチェックは一切行っておりません
今時ポストスクリプトプリンタで文書を印刷する必要性は薄れているでしょうが
私は自分で書いた文書を印刷するためにまだ使っています
ご使用の際はソースコードを御覧下さい
大城貴紀
/* a2psj - A program that converts japanese text to postscript language */
/* print 66 lines a page */
/* for A4 paper only */
/* font size is 10 point */
/* kanji code is euc */
/* written by Takanori Oshiro */
/* 2018/10/31 Bug fix about undisplay of () */
/* 2018/11/1 Bug fix about undisplay of \ */
#include <stdio.h>
#define MAXLINE 66
#define BUFSIZE 8192
int main(void){
int nline = 0; /* current line number */
int c;
char kanji[BUFSIZE]; /* buffer for kanji code */
int i;
printf("%%!PS-Adobe-3.0 EPSF-3.0\n");
printf("%%Definition of mm\n");
printf("/mm {2.834645669 mul} def\n");
printf("/verticalPosition 297 mm 20 mm sub def\n"); /* head and foot margin 20 mm */
printf("/horizontalPosition 25 mm def\n"); /* left margin 25 mm */
printf("/newline {/verticalPosition verticalPosition 3.89393939 mm sub def\n");
printf("\thorizontalPosition verticalPosition moveto } def\n");
printf("/putStr { findfont 10 scalefont setfont show } def\n");
printf("horizontalPosition verticalPosition moveto\n");
while((c = getchar()) != EOF){
if( c == '\n'){
printf("newline\n");
nline++;
if(nline == MAXLINE){
printf("showpage\n");
printf("/verticalPosition 297 mm 20 mm sub def\n");
printf("horizontalPosition verticalPosition moveto\n");
nline = 0;
}
} else if(c == '(' || c == ')'){
printf("(\\%c) /Times-Roman putStr\n",c);
} else if(c == '\\'){
printf("(\\\\) /Times-Roman putStr\n");
} else if(c < 0x80)
printf("(%c) /Times-Roman putStr\n",c);
else {
i = 0;
kanji[i++] = c;
while((c = getchar()) >= 0x80){
kanji[i++] = c;
}
kanji[i] = '\0';
printf("(%s) /Ryumin-Light-EUC-H putStr\n",kanji);
ungetc(c,stdin);
}
}
printf("showpage\n");
return 0;
}