diff --git a/genex/pdf.c b/genex/pdf.c index 47cf29b..e8a7b69 100644 --- a/genex/pdf.c +++ b/genex/pdf.c @@ -17,6 +17,24 @@ #include "pdf.h" +static struct format { + int left; + struct text { + const char *font; + int size; + int y; + } name, path, lib, comment; + int comment_line_skip; +} format = { + .left = 20, + .name = { "Helvetica-Bold", 24, 57 }, + .path = { "Helvetica-Bold", 18, 30 }, + .lib = { "Courier", 12, 75 }, + .comment = { "Helvetica", 12, 600 }, + .comment_line_skip = 14, +}; + + static int children(const struct node *node) { int n = 0; @@ -55,20 +73,24 @@ static void print_path(FILE *file, const struct node *node) static void make_title(FILE *file, const struct node *node, int unit) { - fprintf(file, "gsave 90 rotate 0 setgray\n" - "/Helvetica-Bold findfont 24 scalefont setfont\n" - "20 -57 moveto\n"); + fprintf(file, "gsave 90 rotate 0 setgray\n"); + + fprintf(file, "/%s findfont %d scalefont setfont\n", + format.name.font, format.name.size); + fprintf(file, "%d %d moveto\n", format.left, -format.name.y); ps_string(file, node->canon); fprintf(file, " show\n"); if (node->units > 1) fprintf(file, " ( \\(%c\\)) show\n", 'A'+unit); - fprintf(file, "/Hevetica-Bold findfont 18 scalefont setfont\n"); - fprintf(file, "20 -30 moveto\n"); + fprintf(file, "/%s findfont %d scalefont setfont\n", + format.path.font, format.path.size); + fprintf(file, "%d %d moveto\n", format.left, -format.path.y); print_path(file, node); - fprintf(file, "/Courier findfont 12 scalefont setfont\n"); - fprintf(file, "20 -75 moveto\n"); + fprintf(file, "/%s findfont %d scalefont setfont\n", + format.lib.font, format.lib.size); + fprintf(file, "%d %d moveto\n", format.left, -format.lib.y); ps_string(file, node->lib); fprintf(file, " show\n"); @@ -83,14 +105,16 @@ static void print_comment(FILE *file, const struct line *comment) int lines = 0; int n; - fprintf(file, "gsave 90 rotate 0 setgray\n" - "/Helvetica findfont 12 scalefont setfont\n"); + fprintf(file, "gsave 90 rotate 0 setgray\n"); + fprintf(file, "/%s findfont %d scalefont setfont\n", + format.comment.font, format.comment.size); for (line = comment; line; line = line->next) lines++; n = 0; for (line = comment; line; line = line->next) { n++; - fprintf(file, "20 -%d moveto\n", 600+(n-lines)*14); + fprintf(file, "%d -%d moveto\n", format.left, + format.comment.y+(n-lines)*format.comment_line_skip); ps_string(file, line->s); fprintf(file, " show\n"); }