1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-05 03:47:10 +02:00

genex/pdf.c: use central format definition

... instead of having hard-coded format constants all over the place.
This commit is contained in:
Werner Almesberger 2012-04-17 06:27:44 -03:00
parent 34095c70cb
commit 5a8606b118

View File

@ -17,6 +17,24 @@
#include "pdf.h" #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) static int children(const struct node *node)
{ {
int n = 0; 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) static void make_title(FILE *file, const struct node *node, int unit)
{ {
fprintf(file, "gsave 90 rotate 0 setgray\n" fprintf(file, "gsave 90 rotate 0 setgray\n");
"/Helvetica-Bold findfont 24 scalefont setfont\n"
"20 -57 moveto\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); ps_string(file, node->canon);
fprintf(file, " show\n"); fprintf(file, " show\n");
if (node->units > 1) if (node->units > 1)
fprintf(file, " ( \\(%c\\)) show\n", 'A'+unit); fprintf(file, " ( \\(%c\\)) show\n", 'A'+unit);
fprintf(file, "/Hevetica-Bold findfont 18 scalefont setfont\n"); fprintf(file, "/%s findfont %d scalefont setfont\n",
fprintf(file, "20 -30 moveto\n"); format.path.font, format.path.size);
fprintf(file, "%d %d moveto\n", format.left, -format.path.y);
print_path(file, node); print_path(file, node);
fprintf(file, "/Courier findfont 12 scalefont setfont\n"); fprintf(file, "/%s findfont %d scalefont setfont\n",
fprintf(file, "20 -75 moveto\n"); format.lib.font, format.lib.size);
fprintf(file, "%d %d moveto\n", format.left, -format.lib.y);
ps_string(file, node->lib); ps_string(file, node->lib);
fprintf(file, " show\n"); fprintf(file, " show\n");
@ -83,14 +105,16 @@ static void print_comment(FILE *file, const struct line *comment)
int lines = 0; int lines = 0;
int n; int n;
fprintf(file, "gsave 90 rotate 0 setgray\n" fprintf(file, "gsave 90 rotate 0 setgray\n");
"/Helvetica findfont 12 scalefont setfont\n"); fprintf(file, "/%s findfont %d scalefont setfont\n",
format.comment.font, format.comment.size);
for (line = comment; line; line = line->next) for (line = comment; line; line = line->next)
lines++; lines++;
n = 0; n = 0;
for (line = comment; line; line = line->next) { for (line = comment; line; line = line->next) {
n++; 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); ps_string(file, line->s);
fprintf(file, " show\n"); fprintf(file, " show\n");
} }