From dccaf7eff26ca69b0e58ef314bdc209d605e6a01 Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Wed, 18 Jul 2007 00:56:50 +0000 Subject: [PATCH] Attempting to work around fprintf(... "%f" ...) localization in PS printing. --- docs/CHANGES.txt | 5 +++++ src/postscript_print.c | 25 ++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 44e5a1e14..d52957681 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -103,6 +103,11 @@ $Id$ * Improved comments near gettext() calls in the source code, to provide useful descriptions of each string in the POT (translation template). + * Bug Fixes + --------- + * PostScript scale and translation values were being localized + (so, e.g., "N.M" would be "N,M") due to use of printf(). Fixed. + 2007.July.1 (0.9.17) diff --git a/src/postscript_print.c b/src/postscript_print.c index a745caf42..2ca7307d8 100644 --- a/src/postscript_print.c +++ b/src/postscript_print.c @@ -36,7 +36,7 @@ implied warranty. - June 24, 2007 - June 25, 2007 + June 24, 2007 - July 17, 2007 $Id$ */ @@ -63,6 +63,19 @@ #define my_min(x,y) ((x < y) ? (x) : (y)) +int f2int(float f); +int f2dec(float f); + +int f2int(float f) +{ + return ((int)f); +} + +int f2dec(float f) +{ + return (int)(f - (((int)f) * 100)); +} + /* Actually save the PostScript data to the file stream: */ int do_ps_save(FILE * fi, // const char *restrict const fname, @@ -234,14 +247,16 @@ int do_ps_save(FILE * fi, /* 'translate' moves the user space origin to a new position with respect to the current page, leaving the orientation of the axes and the unit lengths unchanged. */ - fprintf(fi, "%.2f %.2f translate\n", tlate_x, tlate_y); + fprintf(fi, "%d.%02d %d.%02d translate\n", + f2int(tlate_x), f2dec(tlate_x), + f2int(tlate_y), f2dec(tlate_y)); /* 'scale' modifies the unit lengths independently along the current x and y axes, leaving the origin location and the orientation of the axes unchanged. */ - fprintf(fi, "%.2f %.2f scale\n", - (float) printed_img_w * scale, - (float) printed_img_h * scale); + fprintf(fi, "%d.%02d %d.%02d scale\n", + f2int(printed_img_w * scale), f2dec(printed_img_w * scale), + f2int(printed_img_h * scale), f2dec(printed_img_h * scale)); /* Rotate the image */ if (rotate)