📄 postscript.c
字号:
spaces = get_spaces (spaces, right_space); strcpy ((char *) t + lineLength, (char *) spaces); strcat (t, option_continuation_string); p = (unsigned char *) t; } else { temp = (unsigned char *) ""; if (strlen ((char *) p) > maxLength) p[maxLength] = '\0'; p = (unsigned char *) strdup ((char *) p); lineLength = strlen ((char *) p); } if (rightMargin == 0) { spaces = get_spaces (spaces, 0); rightMargin = lineLength; } else { spaces = get_spaces (spaces, rightMargin - lineLength); } q = (unsigned char *) malloc (strlen ((char *) spaces) + strlen ((char *) p) + 1); strcpy ((char *) q, (char *) spaces); strcat ((char *) q, (char *) p); zfree (p); printLine (q); zfree (q); p = temp; maxLength = chars_per_line * 3 / 4; } zfree (spaces);}static void prolog (void){ struct tm *tm; time_t t; time (&t); tm = localtime (&t); fprintf (outfile, "%%!PS-Adobe-2.0\n"); if (title) fprintf (outfile, "%%%%Title: %s\n", title); fprintf (outfile, "%%%%Creator: Cooledit, text editor and IDE.\n"); fprintf (outfile, "%%%%CreationDate: (%d %d, %d) (%2d:%02d)\n", tm->tm_mon + 1, tm->tm_mday, tm->tm_year + 1900, tm->tm_hour, tm->tm_min); fprintf (outfile, "%%%%For: %s\n", /* username ******* */ "(unknown)"); fprintf (outfile, "%%%%Pages: (atend)\n"); fprintf (outfile, "%%%%DocumentFonts: %s", postscript_option_font); if (postscript_option_line_numbers) fprintf (outfile, " %s", postscript_option_line_number_font); if (postscript_option_show_header) fprintf (outfile, " %s", postscript_option_header_font); fprintf (outfile, "\n"); fprintf (outfile, "\%%%%EndComments\n\/S{moveto show}bind def\n\/M/moveto load def\n\/L/lineto load def\n\/SF/setfont load def\n\"); if (isoencoding_not_builtin) { fprintf (outfile, "\ISOLatin1Encoding where { pop } { ISOLatin1Encoding\n\[/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/space\n\/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright\n\/parenleft/parenright/asterisk/plus/comma/minus/period/slash/zero/one\n\/two/three/four/five/six/seven/eight/nine/colon/semicolon/less/equal\n\/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O/P/Q/R/S\n\/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum\n\/underscore/quoteleft/a/b/c/d/e/outfile/g/h/i/j/k/l/m/n/o/p/q/r/s\n\/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef/.notdef\n\/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef\n\/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/dotlessi/grave\n\/acute/circumflex/tilde/macron/breve/dotaccent/dieresis/.notdef/ring\n\/cedilla/.notdef/hungarumlaut/ogonek/caron/space/exclamdown/cent\n\/sterling/currency/yen/brokenbar/section/dieresis/copyright/ordfeminine\n\/guillemotleft/logicalnot/hyphen/registered/macron/degree/plusminus\n\/twosuperior/threesuperior/acute/mu/paragraph/periodcentered/cedilla\n\/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters\n\/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE\n\/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex\n\/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis\n\/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn\n\/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae\n\/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex\n\/idieresis/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide\n\/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]\n\def %%ISOLatin1Encoding\n\} ifelse\n\"); } fprintf (outfile, "%%%%BeginProcSet: newencode 1.0 0\n\/NE { %%def\n\ findfont begin\n\ currentdict dup length dict begin\n\ { %%forall\n\ 1 index/FID ne {def} {pop pop} ifelse\n\ } forall\n\ /FontName exch def\n\ /Encoding exch def\n\ currentdict dup\n\ end\n\ end\n\ /FontName get exch definefont pop\n\} bind def\n\%%%%EndProcSet: newencode 1.0 0\n\%%%%EndProlog\n\%%%%BeginSetup\n\"); fprintf (outfile, "ISOLatin1Encoding /%s-ISO/%s NE\n", postscript_option_font, postscript_option_font); if (postscript_option_show_header) fprintf (outfile, "ISOLatin1Encoding /%s-ISO/%s NE\n", postscript_option_header_font, postscript_option_header_font); fprintf (outfile, "/F1/%s-ISO findfont %.2g scalefont def\n", postscript_option_font, font_size); if (postscript_option_line_numbers) fprintf (outfile, "/F2/%s findfont %d scalefont def\n", postscript_option_line_number_font, postscript_option_line_number_size); if (postscript_option_show_header) fprintf (outfile, "/F3/%s-ISO findfont %d scalefont def\n", postscript_option_header_font, postscript_option_header_font_size); fprintf (outfile, "F1 SF\n"); fprintf (outfile, "%%%%EndSetup\n");}void postscript_print (void){ unsigned char *p = 0; double llx = 0.0, lly = 0.0, urx = 0.0, ury = 0.0; struct stat st; struct tm *tm = 0; outfile = 0; page_no = 0; line_no = 0; cur_col = 100; total_pages = 0; cur_pos = -1; top = 0; right_edge = 0; no_columns = 0; home_pos = 0; bottom_pos = 0; sep_bar_pos = 0; font_size = 0.0; line_height = 0.0; char_width = 0.0; col_width = 0.0; chars_per_line = 0; cour_char_width = 600; lineNoOut = 0; if (!option_continuation_string) option_continuation_string = (unsigned char *) strdup ("~"); if (title) free (title); title = 0; if (postscript_option_title) title = ps_string (postscript_option_title); if (postscript_option_landscape) { top = postscript_option_page_right_edge; right_edge = postscript_option_page_top; postscript_option_left_margin = postscript_option_right_margin; /* this is a dirty one */ no_columns = postscript_option_columns; font_size = postscript_option_font_size ? postscript_option_font_size : 7; if (postscript_option_footline_in_landscape) { postscript_option_top_margin = 30; postscript_option_bottom_margin = 30; home_pos = top - postscript_option_top_margin - postscript_option_header_height; bottom_pos = postscript_option_bottom_margin + postscript_option_header_height; } else { postscript_option_top_margin = 45; postscript_option_bottom_margin = 30; home_pos = top - postscript_option_top_margin - postscript_option_header_height; bottom_pos = postscript_option_bottom_margin; } } else { top = postscript_option_page_top; right_edge = postscript_option_page_right_edge; no_columns = postscript_option_columns; font_size = postscript_option_font_size ? postscript_option_font_size : 10; postscript_option_top_margin = 45; postscript_option_bottom_margin = 45; home_pos = top - postscript_option_top_margin - (postscript_option_show_header ? postscript_option_header_height : 0); bottom_pos = postscript_option_bottom_margin + postscript_option_header_height; } col_width = (double) (right_edge - postscript_option_left_margin - postscript_option_right_margin - (no_columns - 1) * postscript_option_col_separation) / no_columns; sep_bar_pos = (right_edge - postscript_option_left_margin - postscript_option_right_margin) / no_columns; if (!font_size) font_size = (double) ((double) col_width / postscript_option_chars_per_line) / (cour_char_width / 1000); if (postscript_option_chars_per_line) font_size = (double) ((double) col_width / postscript_option_chars_per_line) / (cour_char_width / 1000); line_height = font_size * 1.08; char_width = cour_char_width * font_size / 1000; chars_per_line = (double) col_width / char_width + 1;/* Compute the box for the page headers. */ box_format = (unsigned char *) "%.1f %.1f M %.1f %.1f L %.1f %.1f L %.1f %.1f L closepath \n"; llx = postscript_option_left_margin - 10; lly = top - postscript_option_top_margin - postscript_option_header_font_size * 1.3; urx = right_edge - postscript_option_right_margin + 10; ury = top - postscript_option_top_margin; top_box = (unsigned char *) malloc (1024); sprintf ((char *) top_box, (char *) box_format, llx, lly, urx, lly, urx, ury, llx, ury); strcat (top_box, "gsave .95 setgray fill grestore stroke\n"); lly = postscript_option_bottom_margin; ury = lly + postscript_option_header_font_size * 1.3; bot_box = (unsigned char *) malloc (1024); sprintf ((char *) bot_box, (char *) box_format, llx, lly, urx, lly, urx, ury, llx, ury); strcat (bot_box, "gsave .95 setgray fill grestore stroke\n");/* Open the output pipe or file. */ if (postscript_option_file) { int r; r = stat ((char *) postscript_option_file, &st); if (!r) if (postscript_dialog_exists) if (!(*postscript_dialog_exists) (postscript_option_file)) goto postscript_done; outfile = fopen ((char *) postscript_option_file, "w+"); if (!outfile) { if (postscript_dialog_cannot_open) (*postscript_dialog_cannot_open) (postscript_option_file); goto postscript_done; } } else if (postscript_option_pipe) { outfile = (FILE *) popen ((char *) postscript_option_pipe, "w"); if (!outfile) { if (postscript_dialog_cannot_open) (*postscript_dialog_cannot_open) (postscript_option_pipe); goto postscript_done; } } if (postscript_option_plain_text) { while ((p = (*postscript_get_next_line) (p))) fprintf (outfile, "%s\n", p); goto postscript_done; } prolog (); filedate[0] = '\0'; time (&st.st_mtime); tm = localtime (&st.st_mtime); get_file_time (filedate, st.st_mtime, 1); if (title) header = title; else header = 0; page_no = 0; line_no = 0; while ((p = (*postscript_get_next_line) (p))) { line_no++; if (postscript_option_line_numbers && ((line_no % 5) == 0)) lineNoOut = line_no; if (p[0] == 014) { /* form feed */ strcpy ((char *) p, (char *) p + 1); /* chop off first unsigned char */ cur_pos = -1; if (!*p) p = postscript_get_next_line (p); if (!p) break; } p = expand_tabs (p); /* expand tabs */ if (strlen ((char *) p) <= chars_per_line) { printLine (p); } else { printLongLines (p); } } /* while (each line) */ cur_pos = -1; /* this will force a new column next time */ cur_col = 100; /* this will force a new page next time */ end_page (); fprintf (outfile, "%%%%Trailer\n"); fprintf (outfile, "%%%%Pages: %d\n", total_pages); postscript_done: free (top_box); free (bot_box); if (p) free (p); if (outfile) { if (postscript_option_file) { fflush (outfile); fclose (outfile); } else { fflush (outfile); pclose (outfile); } } outfile = 0; if (title) free (title); title = 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -