1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-29 17:51:53 +02:00

gencat/pdf.c: make "format" a pointer, not a copy of the format settings

This commit is contained in:
Werner Almesberger 2012-07-12 02:33:29 -03:00
parent e4481450ec
commit 7cbd51ee7b

View File

@ -65,7 +65,9 @@ static struct format {
.index_column_skip = 140,
.index_lines = 63,
.index_columns = 4,
}, format;
};
static const struct format *format;
static int total, done = 0;
@ -139,23 +141,23 @@ static void make_index(FILE *file, const struct node *node)
fprintf(file, "[ /Title (Index) /Count 0 /OUT pdfmark\n");
fprintf(file, "/%s findfont %d scalefont setfont\n",
format.index.font, format.index.size);
fprintf(file, "gsave %s 0 setgray\n", format.overlay_setup);
format->index.font, format->index.size);
fprintf(file, "gsave %s 0 setgray\n", format->overlay_setup);
for (p = idx; p != idx+n; p++) {
if (line == format.index_lines) {
if (line == format->index_lines) {
line = 0;
col++;
}
if (col == format.index_columns) {
if (col == format->index_columns) {
fprintf(file, "grestore showpage\n");
fprintf(file, "gsave %s 0 setgray\n",
format.overlay_setup);
format->overlay_setup);
col = 0;
}
fprintf(file, "newpath %d -%d moveto currentpoint\n",
format.left+col*format.index_column_skip,
format.index.y+line*format.index_line_skip);
format->left+col*format->index_column_skip,
format->index.y+line*format->index_line_skip);
fprintf(file, "[ /Rect [ ");
ps_string(file, p->s);
@ -207,11 +209,11 @@ static void make_title(FILE *file, const struct node *node, int unit)
{
const struct name *name;
fprintf(file, "gsave %s 0 setgray\n", format.overlay_setup);
fprintf(file, "gsave %s 0 setgray\n", format->overlay_setup);
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);
format->name.font, format->name.size);
fprintf(file, "%d %d moveto\n", format->left, -format->name.y);
for (name = node->e->names; name; name = name->next) {
if (name != node->e->names)
fprintf(file, "(, ) show 0.5 setgray\n");
@ -226,13 +228,13 @@ static void make_title(FILE *file, const struct node *node, int unit)
fprintf(file, " ( \\(%c\\)) show\n", 'A'+unit);
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);
format->path.font, format->path.size);
fprintf(file, "%d %d moveto\n", format->left, -format->path.y);
print_path(file, node);
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);
format->lib.font, format->lib.size);
fprintf(file, "%d %d moveto\n", format->left, -format->lib.y);
ps_string(file, node->e->file->path);
fprintf(file, " show\n");
@ -246,16 +248,16 @@ static void print_comment(FILE *file, const struct line *comment)
int lines = 0;
int n;
fprintf(file, "gsave %s 0 setgray\n", format.overlay_setup);
fprintf(file, "gsave %s 0 setgray\n", format->overlay_setup);
fprintf(file, "/%s findfont %d scalefont setfont\n",
format.comment.font, format.comment.size);
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, "%d -%d moveto\n", format.left,
format.comment.y+(n-lines)*format.comment_line_skip);
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");
}
@ -279,7 +281,7 @@ static void convert_comp(const struct node *node, FILE *out)
make_title(out, node, i);
if (!i && node->comment)
print_comment(out, node->comment);
fprintf(out, "gsave %s\n", format.comp_setup);
fprintf(out, "gsave %s\n", format->comp_setup);
node->e->file->lib->ps_entry(out, lib, node->e, i);
fprintf(out, "\ngrestore\n");
}
@ -324,9 +326,9 @@ void make_pdf(int pdf, int use_portrait)
int res;
if (use_portrait)
format = portrait;
format = &portrait;
else
format = landscape;
format = &landscape;
if (pdf)
out = popen(
"gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=- "
@ -337,7 +339,7 @@ void make_pdf(int pdf, int use_portrait)
perror("gs");
exit(1);
}
fprintf(out, "%%!PS\n%s\n", format.file_setup);
fprintf(out, "%%!PS\n%s\n", format->file_setup);
make_index(out, tree);
total = count_tree(tree);
convert_tree(tree, out);