GNOME Bugzilla – Bug 130814
Broken PS generation in non-C locales
Last modified: 2004-12-22 21:47:04 UTC
Here's a patch from JDS that fixes it, although I notice it does use setlocale ;) Comments in the associated bug - The issue with the pdf is even seen in C locale. "Invalid operator found" error. I have created a patch for rectifying the PS generation in some locales. In patch, LC_NUMERIC should be set to C when printing floating numbers into PS file, otherwise in some locales where the decimal separater is comma, PS will be confused.
Created attachment 23091 [details] [review] ps locale generation fix
I don't think we should play with the locale just to print some floating point numbers.
To be more specific: Bug 109446 specifically mentions that gnome-print should never use the not thread-safe setlocale. So the proposed patch is definitely not the correct way to fix this bug. In fact, gnome-print has also other places with the same problem, eg. in gnome_print_ps2_image.
Can we get one of those invalid postscript files? Preferably a small one? Created with current cvs HEAD? gnome_print_ps2_fprintf already conatains one of those undesirable setlocale calls, so I am not sure where the invalid decimal separator comes from.
The approach in the rest of gnomep-print was to set and reset the locale for every operation which is damn ugly. Going forward what I'd like to do is just adopt a pango-esque scale factor and only ouput integers. For now it would be helpful to get 1) The locale that failed 2) which application was producing the output 3) any input files necessary for (2)
We don't output that many floating point values. We could probably get away with using a simple "%d.%06d" type of solution.
I am in the process of getting rid of those setlocales by using glib's g_ascii_formatd. I don't think we can ever get competely rid of floating point numbers since we do need to output postscript.
I have changed all the relevant code to be locale independent (ie. no use of %f in calls to ...printf). So this issue should be resolved in current cvs HEAD. Please reopen if you should still find a problem with PS generation in non-C locale.
gnome-print 2.6.1 Debian unstable Locale set to lt_LT.UTF-8 It seems, that I have found a regression here - I was fighting with this issue for 2 weeks, thinking that's my bogus printer configuration. The only thing surprised me - why test page from cups or any page from mozilla firefox prints OK and pages from any gnome program haven't been printed at all. See buggy ps file attached. Printing worked again only after I have put LC_NUMERIC="POSIX" in /etc/environment file. Please reopen and fix this bug again, since LC_NUMERIC="POSIX" is ugly and incorrect with many locales.
Created attachment 28775 [details] Bogus PS file This is an example of file created if LANG is set to lt_LT.UTF-8
From the postscript file: /FullName (Andale Mono Regular) readonly def /FamilyName (Andale Mono) readonly def /Weight (Book) readonly def /ItalicAngle 0,000000 def /isFixedPitch true def /UnderlinePosition -100 def /UnderlineThickness 50 def The problem is the comma in the /ItalicAngle line.
It arises from line 730 in gp-tt-t1.c where we have: "/ItalicAngle %f def\n"
A simple fix seems reasonable here given that the code is gone in head.