#include #include /* usage */ /* type1tomf psfile > mffile */ int nohint; main(ac,ag) char **ag; { FILE *fp; int len,kcode; char buf[4096]; if(ac<2)exit(1); if(!strcmp(ag[1],"-nohint"))nohint=1,ag++; if((fp=fopen(ag[1],"r"))==NULL){ fprintf(stderr,"File %s is not found\n",ag[1]); exit(1); } print_header(); while(fgets(buf,4096,fp)!=NULL){ len=strlen(buf); if(buf[0]=='<' && !strncmp(buf+len-6 ,"CompD",5)){ kcode=strtol(buf+len-12,NULL,16); print_kanji(kcode,buf); } } printf("end"); fclose(fp); return 0; } print_header() { printf("font_size 10pt#;\n"); printf("mode_setup;\n"); printf("turningcheck := 0;\n"); } print_kanji_header(kcode) { printf("beginchar(%d,10pt#,10pt#,0pt#);\n",kcode&255); } int hex2bin(hexstr,binstr) char *hexstr; unsigned char *binstr; { int len,c; for(len=0,hexstr++;*hexstr!='>'&&*hexstr;hexstr+=2,len++){ c=(*hexstr>='a'?*hexstr-'a'+10:*hexstr-'0'); *binstr++ = (c<<4)|(*(hexstr+1)>='a'?*(hexstr+1)-'a'+10:*(hexstr+1)-'0'); } return len; } decrypt_str(cipher,plain,len) unsigned char *cipher,*plain; { unsigned short r=4330,c1=52845,c2=22719; while(--len>=0){ *plain++=(*cipher ^ (r>>8)); r=(*cipher++ +r)*c1+c2; } } show_charstr(plain,len) unsigned char *plain; { unsigned char *limit=plain+len,uc; int n; while(plainPI) return (difft-PI2); else return difft; } double allangle(p) { int i; double t0,t1,t2,allt; for(i=0;points[i+1].y==points[i].y && points[i+1].x==points[i].x;i++); t0=t1=atan2((double)(points[i+1].y-points[i].y),(double)(points[i+1].x-points[i].x)); i++; for(allt=0.0;i50)return 1; if(dy0==0 && dx0==0){ if((dy3==0 && dx3==0)||(x2==x0 && y2==y0)) return 0; dx0=x2-x0;dy0=y2-y0; } t0=atan2((double)dy0,(double)dx0); if(dx3==0 && dy3==0){ if((x1==x3 && y1==y3)) return 0; dx3=x3-x1;dy3=y3-y1; } t3=atan2((double)dy3,(double)dx3); difft=difftheta(t3,t0); if(difft<-0.4 || difft>0.4) return 1; return 0; } flush_point(p) { int i; if(p>0){ for(i=0;ip) printf("\n"); else printf(" .. (x%d,y%d)\n", lcount+i+2,lcount+i+2); } else { printf(" -- (x%d,y%d)\n", lcount+(i+2)%p,lcount+(i+2)%p); } i+=2; break; case LINE: printf(" -- (x%d,y%d)\n",lcount+i,lcount+i); break; } } if(points[p-1].x!=points[0].x || points[p-1].y!=points[0].y){ printf(" .. (x%d,y%d)",lcount,lcount); } printf(" .. cycle;\n"); lcount+=p; } } struct stems{ int from,width,n; } hstems[256],vstems[256]; int hstem,vstem,checked; int compstem(c1,c2) struct stems *c1,*c2; { return c1->from - c2->from; } int toph,both,topv,botv; check_stems() { int i; if(hstem){ hstems[hstem].from=0; hstems[hstem++].width=0; hstems[hstem].from=1000; hstems[hstem++].width=0; qsort(hstems,hstem,sizeof(struct stems),compstem); for(i=0;i