Attempting to work around fprintf(... "%f" ...) localization in PS printing.

This commit is contained in:
William Kendrick 2007-07-18 00:56:50 +00:00
parent 21ea42f38f
commit dccaf7eff2
2 changed files with 25 additions and 5 deletions

View file

@ -103,6 +103,11 @@ $Id$
* Improved comments near gettext() calls in the source code, to provide * Improved comments near gettext() calls in the source code, to provide
useful descriptions of each string in the POT (translation template). 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) 2007.July.1 (0.9.17)

View file

@ -36,7 +36,7 @@
implied warranty. implied warranty.
June 24, 2007 - June 25, 2007 June 24, 2007 - July 17, 2007
$Id$ $Id$
*/ */
@ -63,6 +63,19 @@
#define my_min(x,y) ((x < y) ? (x) : (y)) #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: */ /* Actually save the PostScript data to the file stream: */
int do_ps_save(FILE * fi, int do_ps_save(FILE * fi,
// const char *restrict const fname, // 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 /* 'translate' moves the user space origin to a new position with
respect to the current page, leaving the orientation of the axes and respect to the current page, leaving the orientation of the axes and
the unit lengths unchanged. */ 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 /* 'scale' modifies the unit lengths independently along the current
x and y axes, leaving the origin location and the orientation of the x and y axes, leaving the origin location and the orientation of the
axes unchanged. */ axes unchanged. */
fprintf(fi, "%.2f %.2f scale\n", fprintf(fi, "%d.%02d %d.%02d scale\n",
(float) printed_img_w * scale, f2int(printed_img_w * scale), f2dec(printed_img_w * scale),
(float) printed_img_h * scale); f2int(printed_img_h * scale), f2dec(printed_img_h * scale));
/* Rotate the image */ /* Rotate the image */
if (rotate) if (rotate)