diff --git a/README b/README index 7750626..68ff9a2 100644 --- a/README +++ b/README @@ -21,6 +21,7 @@ Prerequisites: - fig2dev - ImageMagick - Gtk+ 2.x development package (libgtk2.0-dev or similar) +- Liberation Fonts (ttf-liberation or similar) Check out the repository: diff --git a/gui_style.h b/gui_style.h index cf101d9..f3c16d9 100644 --- a/gui_style.h +++ b/gui_style.h @@ -47,7 +47,8 @@ #define FRAME_EYE_R1 3 #define FRAME_EYE_R2 5 -#define ITEM_LIST_FONT "Courier Bold 8" +#define ITEM_LIST_FONT "Liberation Mono 8" +//#define ITEM_LIST_FONT "Courier Bold 8" #define SELECT_R 6 /* pixels within which we select */ diff --git a/inst.h b/inst.h index 0351d13..d5a29a3 100644 --- a/inst.h +++ b/inst.h @@ -139,10 +139,12 @@ extern struct inst *curr_frame; #define FOR_INST_PRIOS_DOWN(prio) \ for (prio = ip_n-1; prio != (enum inst_prio) -1; prio--) +#define FOR_PKG_INSTS(pkg, prio, inst) \ + for (inst = (pkg)->insts[prio]; inst; inst = inst->next) + #define FOR_ALL_INSTS(i, prio, inst) \ for (i = 0; i != 2; i++) \ - for (inst = (i ? active_pkg : pkgs)->insts[prio]; inst; \ - inst = inst->next) + FOR_PKG_INSTS(i ? active_pkg : pkgs, prio, inst) void inst_select_outside(void *item, void (*deselect)(void *item)); diff --git a/postscript.c b/postscript.c index fb102a2..8af30e4 100644 --- a/postscript.c +++ b/postscript.c @@ -247,7 +247,6 @@ static void ps_meas(FILE *file, const struct inst *inst, c = add_vec(a1, b1); d = sub_vec(b1, a1); -//s = stralloc_printf("%s%lgmm", meas->label ? meas->label : "", len); fprintf(file, "gsave %d %d moveto\n", c.x/2, c.y/2); fprintf(file, " /Helvetica-Bold findfont dup\n"); fprintf(file, " (%s) %d %d realsize\n", s, @@ -329,16 +328,21 @@ static void ps_draw_package(FILE *file, const struct pkg *pkg, double zoom) { enum inst_prio prio; const struct inst *inst; - int i; fprintf(file, "gsave %f dup scale\n", zoom); ps_cross(file, pkgs->insts[ip_frame]); - FOR_INST_PRIOS_UP(prio) - FOR_ALL_INSTS(i, prio, inst) + FOR_INST_PRIOS_UP(prio) { + FOR_PKG_INSTS(pkgs, prio, inst) ps_background(file, prio, inst); - FOR_INST_PRIOS_UP(prio) - FOR_ALL_INSTS(i, prio, inst) + FOR_PKG_INSTS(pkg, prio, inst) + ps_background(file, prio, inst); + } + FOR_INST_PRIOS_UP(prio) { + FOR_PKG_INSTS(pkgs, prio, inst) ps_foreground(file, prio, inst); + FOR_PKG_INSTS(pkg, prio, inst) + ps_foreground(file, prio, inst); + } fprintf(file, "grestore\n"); } @@ -368,7 +372,24 @@ static void ps_header(FILE *file, const struct pkg *pkg) } -static void ps_package(FILE *file, const struct pkg *pkg) + +static void ps_page(FILE *file, int page) +{ + fprintf(file, "%%%%Page: %d %d\n", page, page); + + fprintf(file, "%%%%BeginPageSetup\n"); + fprintf(file, +"currentpagedevice /PageSize get\n" +" aload pop\n" +" 2 div exch 2 div exch\n" +" translate\n" +" 72 %d div 1000 div dup scale\n", + (int) MIL_UNITS); + fprintf(file, "%%%%EndPageSetup\n"); +} + + +static void ps_package(FILE *file, const struct pkg *pkg, int page) { struct bbox bbox; unit_type x, y; @@ -376,6 +397,7 @@ static void ps_package(FILE *file, const struct pkg *pkg) double f; unit_type c, d; + ps_page(file, page); ps_header(file, pkg); x = 2*PAGE_HALF_WIDTH-2*PS_DIVIDER_BORDER; @@ -465,17 +487,17 @@ static void ps_package(FILE *file, const struct pkg *pkg) /* ----- File level -------------------------------------------------------- */ -static void prologue(FILE *file) +static void prologue(FILE *file, int pages) { - fprintf(file, "%%!PS\n"); + fprintf(file, "%%!PS-Adobe-3.0\n"); + fprintf(file, "%%%%Pages: %d\n", pages); + fprintf(file, "%%%%EndComments\n"); - fprintf(file, -"currentpagedevice /PageSize get\n" -" aload pop\n" -" 2 div exch 2 div exch\n" -" translate\n" -" 72 %d div 1000 div dup scale\n", - (int) MIL_UNITS); + fprintf(file, "%%%%BeginDefaults\n"); + fprintf(file, "%%%%PageResources: font Helvetica Helvetica-Bold\n"); + fprintf(file, "%%%%EndDefaults\n"); + + fprintf(file, "%%%%BeginProlog\n"); fprintf(file, "/dotpath {\n" @@ -581,6 +603,8 @@ fprintf(file, "/realsize {\n" " 254 div 72 mul 1000 div 0 matrix currentmatrix idtransform pop\n" " } def\n"); + + fprintf(file, "%%%%EndProlog\n"); } @@ -592,8 +616,17 @@ static void epilogue(FILE *file) int postscript(FILE *file) { - prologue(file); - ps_package(file, active_pkg); + struct pkg *pkg; + int pages; + + for (pkg = pkgs; pkg; pkg = pkg->next) + if (pkg->name) + pages++; + prologue(file, pages); + pages = 0; + for (pkg = pkgs; pkg; pkg = pkg->next) + if (pkg->name) + ps_package(file, pkg, ++pages); epilogue(file); fflush(file);