mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-29 19:35:21 +02:00
gencat/pdf.c: make "format" a pointer, not a copy of the format settings
This commit is contained in:
parent
e4481450ec
commit
7cbd51ee7b
48
gencat/pdf.c
48
gencat/pdf.c
@ -65,7 +65,9 @@ static struct format {
|
|||||||
.index_column_skip = 140,
|
.index_column_skip = 140,
|
||||||
.index_lines = 63,
|
.index_lines = 63,
|
||||||
.index_columns = 4,
|
.index_columns = 4,
|
||||||
}, format;
|
};
|
||||||
|
|
||||||
|
static const struct format *format;
|
||||||
|
|
||||||
static int total, done = 0;
|
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, "[ /Title (Index) /Count 0 /OUT pdfmark\n");
|
||||||
|
|
||||||
fprintf(file, "/%s findfont %d scalefont setfont\n",
|
fprintf(file, "/%s findfont %d scalefont setfont\n",
|
||||||
format.index.font, format.index.size);
|
format->index.font, format->index.size);
|
||||||
fprintf(file, "gsave %s 0 setgray\n", format.overlay_setup);
|
fprintf(file, "gsave %s 0 setgray\n", format->overlay_setup);
|
||||||
|
|
||||||
for (p = idx; p != idx+n; p++) {
|
for (p = idx; p != idx+n; p++) {
|
||||||
if (line == format.index_lines) {
|
if (line == format->index_lines) {
|
||||||
line = 0;
|
line = 0;
|
||||||
col++;
|
col++;
|
||||||
}
|
}
|
||||||
if (col == format.index_columns) {
|
if (col == format->index_columns) {
|
||||||
fprintf(file, "grestore showpage\n");
|
fprintf(file, "grestore showpage\n");
|
||||||
fprintf(file, "gsave %s 0 setgray\n",
|
fprintf(file, "gsave %s 0 setgray\n",
|
||||||
format.overlay_setup);
|
format->overlay_setup);
|
||||||
col = 0;
|
col = 0;
|
||||||
}
|
}
|
||||||
fprintf(file, "newpath %d -%d moveto currentpoint\n",
|
fprintf(file, "newpath %d -%d moveto currentpoint\n",
|
||||||
format.left+col*format.index_column_skip,
|
format->left+col*format->index_column_skip,
|
||||||
format.index.y+line*format.index_line_skip);
|
format->index.y+line*format->index_line_skip);
|
||||||
|
|
||||||
fprintf(file, "[ /Rect [ ");
|
fprintf(file, "[ /Rect [ ");
|
||||||
ps_string(file, p->s);
|
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;
|
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",
|
fprintf(file, "/%s findfont %d scalefont setfont\n",
|
||||||
format.name.font, format.name.size);
|
format->name.font, format->name.size);
|
||||||
fprintf(file, "%d %d moveto\n", format.left, -format.name.y);
|
fprintf(file, "%d %d moveto\n", format->left, -format->name.y);
|
||||||
for (name = node->e->names; name; name = name->next) {
|
for (name = node->e->names; name; name = name->next) {
|
||||||
if (name != node->e->names)
|
if (name != node->e->names)
|
||||||
fprintf(file, "(, ) show 0.5 setgray\n");
|
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, " ( \\(%c\\)) show\n", 'A'+unit);
|
||||||
|
|
||||||
fprintf(file, "/%s findfont %d scalefont setfont\n",
|
fprintf(file, "/%s findfont %d scalefont setfont\n",
|
||||||
format.path.font, format.path.size);
|
format->path.font, format->path.size);
|
||||||
fprintf(file, "%d %d moveto\n", format.left, -format.path.y);
|
fprintf(file, "%d %d moveto\n", format->left, -format->path.y);
|
||||||
print_path(file, node);
|
print_path(file, node);
|
||||||
|
|
||||||
fprintf(file, "/%s findfont %d scalefont setfont\n",
|
fprintf(file, "/%s findfont %d scalefont setfont\n",
|
||||||
format.lib.font, format.lib.size);
|
format->lib.font, format->lib.size);
|
||||||
fprintf(file, "%d %d moveto\n", format.left, -format.lib.y);
|
fprintf(file, "%d %d moveto\n", format->left, -format->lib.y);
|
||||||
ps_string(file, node->e->file->path);
|
ps_string(file, node->e->file->path);
|
||||||
fprintf(file, " show\n");
|
fprintf(file, " show\n");
|
||||||
|
|
||||||
@ -246,16 +248,16 @@ static void print_comment(FILE *file, const struct line *comment)
|
|||||||
int lines = 0;
|
int lines = 0;
|
||||||
int n;
|
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",
|
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)
|
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, "%d -%d moveto\n", format.left,
|
fprintf(file, "%d -%d moveto\n", format->left,
|
||||||
format.comment.y+(n-lines)*format.comment_line_skip);
|
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");
|
||||||
}
|
}
|
||||||
@ -279,7 +281,7 @@ static void convert_comp(const struct node *node, FILE *out)
|
|||||||
make_title(out, node, i);
|
make_title(out, node, i);
|
||||||
if (!i && node->comment)
|
if (!i && node->comment)
|
||||||
print_comment(out, 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);
|
node->e->file->lib->ps_entry(out, lib, node->e, i);
|
||||||
fprintf(out, "\ngrestore\n");
|
fprintf(out, "\ngrestore\n");
|
||||||
}
|
}
|
||||||
@ -324,9 +326,9 @@ void make_pdf(int pdf, int use_portrait)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (use_portrait)
|
if (use_portrait)
|
||||||
format = portrait;
|
format = &portrait;
|
||||||
else
|
else
|
||||||
format = landscape;
|
format = &landscape;
|
||||||
if (pdf)
|
if (pdf)
|
||||||
out = popen(
|
out = popen(
|
||||||
"gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=- "
|
"gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=- "
|
||||||
@ -337,7 +339,7 @@ void make_pdf(int pdf, int use_portrait)
|
|||||||
perror("gs");
|
perror("gs");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
fprintf(out, "%%!PS\n%s\n", format.file_setup);
|
fprintf(out, "%%!PS\n%s\n", format->file_setup);
|
||||||
make_index(out, tree);
|
make_index(out, tree);
|
||||||
total = count_tree(tree);
|
total = count_tree(tree);
|
||||||
convert_tree(tree, out);
|
convert_tree(tree, out);
|
||||||
|
Loading…
Reference in New Issue
Block a user