From c035def16e462189a3019391c1af6ba454c218a6 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 12 Jul 2012 02:41:42 -0300 Subject: [PATCH] gencat/: delegate landscape/portrait setup to library-specific ps_entry This is for the external Postscript. The overlay is still handled in pdf.c --- gencat/comp.c | 4 +++- gencat/fped.c | 4 ++-- gencat/libs.h | 2 +- gencat/pdf.c | 8 +++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gencat/comp.c b/gencat/comp.c index dff9998..42222ed 100644 --- a/gencat/comp.c +++ b/gencat/comp.c @@ -78,8 +78,10 @@ static void comp_add_lib(struct lib *lib, const char *path) static void comp_ps_entry(FILE *file, const struct lib *lib, - const struct entry *e, int unit) + const struct entry *e, int unit, int landscape) { + if (!landscape) + fprintf(file, "-120 700 translate -90 rotate\n"); run_cmd("sym2xps '%s' '%s' %d '%s' '%s'", e->file->path, e->names->s, unit+1, "tmp", "tmp.ps"); cat(file, "tmp.ps"); diff --git a/gencat/fped.c b/gencat/fped.c index 399b1f8..7e76305 100644 --- a/gencat/fped.c +++ b/gencat/fped.c @@ -45,11 +45,11 @@ static void fped_add_lib(struct lib *lib, const char *path) static void fped_ps_entry(FILE *file, const struct lib *lib, - const struct entry *e, int unit) + const struct entry *e, int unit, int landscape) { run_cmd("fped -P '%s' -1 '%s' '%s'", e->file->path, e->names->s, "tmp.ps"); - run_cmd("sed -i -e '/^ /s/\\/sdiv/' tmp.ps"); +// run_cmd("sed -i -e '/^ /s/\\/sdiv/' tmp.ps"); cat(file, "tmp.ps"); } diff --git a/gencat/libs.h b/gencat/libs.h index a939bba..b049a22 100644 --- a/gencat/libs.h +++ b/gencat/libs.h @@ -35,7 +35,7 @@ struct lib { const char *ext; /* file extension, ".lib" or ".fpd" */ void (*add_lib)(struct lib *lib, const char *path); void (*ps_entry)(FILE *file, const struct lib *lib, - const struct entry *e, int unit); + const struct entry *e, int unit, int landscape); struct file *files; }; diff --git a/gencat/pdf.c b/gencat/pdf.c index 293f0c7..a45d1c8 100644 --- a/gencat/pdf.c +++ b/gencat/pdf.c @@ -23,7 +23,6 @@ static struct format { const char *file_setup; const char *overlay_setup; - const char *comp_setup; int left; struct text { const char *font; @@ -38,7 +37,6 @@ static struct format { } landscape = { .file_setup = "%%Orientation: Landscape", .overlay_setup = "90 rotate", - .comp_setup = "", .left = 20, .name = { "Helvetica-Bold", 24, 57 }, .path = { "Helvetica-Bold", 18, 30 }, @@ -53,7 +51,6 @@ static struct format { }, portrait = { .file_setup = "%%Orientation: Portrait", .overlay_setup = "0 790 translate", - .comp_setup = "-120 700 translate -90 rotate", .left = 20, .name = { "Helvetica-Bold", 24, 57 }, .path = { "Helvetica-Bold", 18, 30 }, @@ -281,8 +278,9 @@ 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); - node->e->file->lib->ps_entry(out, lib, node->e, i); + fprintf(out, "gsave\n"); + node->e->file->lib->ps_entry(out, lib, node->e, i, + format == &landscape); fprintf(out, "\ngrestore\n"); } }