From 2e20b2c6d6ff448f5357c69f15f7b8a3203d2d4c Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Thu, 17 Dec 2020 02:49:37 +0100 Subject: [PATCH] escape parenthesis in postscript texts --- src/psprint.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/psprint.c b/src/psprint.c index 6be19006..30d07971 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -237,8 +237,21 @@ static void ps_draw_string_line(int layer, char *s, double x, double y, double s fprintf(fd, "%g %g MT\n", ix, iy); if(rot1) fprintf(fd, "%d rotate\n", rot1*90); fprintf(fd, "1 -1 scale\n"); - fprintf(fd, "(%s)\n", s); - + fprintf(fd, "("); + while(*s) { + switch(*s) { + case '(': + fputs("\\(", fd); + break; + case ')': + fputs("\\)", fd); + break; + default: + fputc(*s, fd); + } + s++; + } + fprintf(fd, ")\n"); if (rot==1 && flip==0) {fprintf(fd, "dup SW pop neg 0 RMT\n");} else if(rot==2 && flip==0) {fprintf(fd, "dup SW pop neg 0 RMT\n");} else if(rot==0 && flip==1) {fprintf(fd, "dup SW pop neg 0 RMT\n");}