libpaper should honor the LC_PAPER instead of /etc/papersize

Bug #393818 reported by Mikko Rantalainen
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libpaper (Debian)
New
Unknown
libpaper (Ubuntu)
Won't Fix
Medium
Unassigned

Bug Description

libpaper should be fixed to honor locale settings instead of always reading /etc/papersize.

I'd prefer removing support for /etc/papersize altogether, but honoring locale settings over a global file would be a nice start.

Actual results (I have "a4" in /etc/papersize):

$ LC_PAPER=en_US.UTF-8 paperconf -s -m
210 mm 297 mm
$ LC_PAPER=en_DK.UTF-8 paperconf -s -m
210 mm 297 mm

Expected results:

$LC_PAPER=en_US.UTF-8 paperconf -s -m
215.9 mm 279.4 mm

$ LC_PAPER=en_DK.UTF-8 paperconf -s -m
210 mm 297 mm

(paperconf should probably also use "-s" or "-i" automatically according to LC_MEASUREMENT)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.04
Release: 9.04
Codename: jaunty

$ apt-cache policy libpaper1
libpaper1:
  Installed: 1.1.23+nmu1
  Candidate: 1.1.23+nmu1
  Version table:
 *** 1.1.23+nmu1 0
        500 http://fi.archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status

$ ldd $(which paperconf)
 linux-vdso.so.1 => (0x00007fffaeffe000)
 libpaper.so.1 => /usr/lib/libpaper.so.1 (0x00007f13a6a7e000)
 libc.so.6 => /lib/libc.so.6 (0x00007f13a670c000)
 /lib64/ld-linux-x86-64.so.2 (0x00007f13a6c82000)

Other information:
libpaper seems to honor PAPERSIZE environment variable. The PAPERSIZE environment variable seems inferior to querying actual paper size because every application that inspects the PAPERSIZE environment variable must include a list of paper names and sizes and such list cannot ever be complete.

Revision history for this message
Pascal De Vuyst (pascal-devuyst) wrote :

Some history lesson:
The LC_PAPER environment variable was not part of the original POSIX standard.
To tackle the default papersize problem the Debian operation system gave birth to libpaper (/etc/papersize), most programs in Debian/Ubuntu use libpaper to retrieve the paper size, CUPS is also compiled with libpaper support.
Later a DRAFT specification of a newer POSIX standard included the LC_PAPER environment variable, glibc was based on this DRAFT specification. But the FINAL version of this POSIX standard didn't include the LC_PAPER environment variable, this is also the current POSIX standard version (http://www.opengroup.org/onlinepubs/9699919799/).

So both methods can be used by application developers depending if they target POSIX compliance or only Linux compliance. In Debian/Ubuntu we could agree on any of these methods and adapt all programs to use this method. Furthermore this effort would be limited to Debian/Ubuntu only as long as there is no new POSIX standard that clearly describes how the default papersize should be retrieved.

Revision history for this message
Pascal De Vuyst (pascal-devuyst) wrote :

There is already a bug report in Debian for this (see bug watch), I added the following comment:

Having two places (LC_PAPER and /etc/papersize) to set the default paper size is confusing.
This is proven by several bug reports in Ubuntu over years, users expect the paper size to change according to LC_PAPER and usually are not aware of /etc/papersize.
Since applications developers can use both LC_PAPER and /etc/papersize to determine the paper size it would be nice if we could let libpaper take its default from the locale, so that if /etc/papersize does not exist or contains "auto" or "locale" that then the paper size is taken from LC_PAPER.
In this way we have one logical location to set the paper size (LC_PAPER) and all applications on the system make use of it.

Changed in libpaper (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
Changed in libpaper (Debian):
status: Unknown → New
Revision history for this message
Bruce Korb (bruce-korb) wrote :

I know I am naive about this, but having been unable to google back
to the original opengroup.org discussion, I wind up wanting to understand
a few things:

1. Isn't paper size a function of the size of the paper in the printer?
    Why is this properly a system setting or a locale issue?

2. Given that you want to put it into a locale, why would you spell
    "letter" as "en_US" and "A4" as "en_UK"? It is difficult for me
    to make sense out of this. I like simple and obvious things.

3. Since POSIX locale means A4 paper and en_US locale means
    permuted directory entry sorting, please continue to support
    /etc/papersize as the primary paper size selector. LC_PAPER
    is not really supported and LC_ALL is, thus, overloaded. I like
    directory listings to be ASCII sorted and my printer is loaded with
    letter sized paper. It seems not to be possible to specify this
    preference, Ulrich Drepper notwithstanding.

Revision history for this message
Bruce Korb (bruce-korb) wrote :

Oh, just to show results:

$ export LC_PAPER=en_US ; locale && ./paper
LANG=C
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=C
height: 297
width: 210
$ export LC_ALL=en_US ; locale && ./paper
LANG=C
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=en_US
height: 279
width: 216

Revision history for this message
Mikko Rantalainen (mira) wrote :

Bruce Korb:
1. You cannot use printer as the only source for the paper size. For example, even if I didn't have any installed printers, I'd expect following command to work:
$ man -t groff paperconf | ps2pdf - - > paperconf.pdf
Which paper size should the resulting PDF file have? Currently the output PDF file paper size depends only on /etc/papersize. If you don't have root access, you cannot currently change the result.

2. LC_PAPER should contain full locale instead of just paper name because LC_PAPER can/could also specify localizations for paper names (e.g. "letter" is "kirje" in Finnish and I'd expect this paper name specified by LC_PAPER locale).

3. POSIX locales include stuff like LC_COLLATE (sorting order) and (only in draft) LC_PAPER for paper size exactly for the reason that you may want to specify these differently. The LC_ALL is only a shortcut to override all specific settings.

Could you specify which program the command "./paper" refers to in your result display? I guess that's not a standard program because you referred to it with a relative path.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Solutions to bug 1130690 were recently uploaded to Raring. With that I think that the issue in this bug report has been addressed in Ubuntu in an alternative way.

When setting the regional formats in Language Support, LC_PAPER is set (together with a bunch of other LC_* variables). The news is that the PAPERSIZE variable is also set to either "a4" or "letter" depending on LC_PAPER. Furthermore, when a user applies the regional format settings system wide, /etc/papersize is updated.

I think it would be appropriate to close the libpaper (Ubuntu) task, but for the case there are aspects on this issue I haven't thought about, I leave it open for now.

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

We have a working fix now, and after almost 4 years it's unlikely that exactly the suggested fix will be implemented.

Changed in libpaper (Ubuntu):
status: Triaged → Won't Fix
Revision history for this message
Mikko Rantalainen (mira) wrote :

If I understood correctly the bug 1130690 is about setting defaults settings correctly (namely, the PAPERSIZE environment variable). This bug was about libpaper honoring LC_PAPER over PAPERSIZE (see rationale in bug description).

Revision history for this message
Gunnar Hjalmarsson (gunnarhj) wrote :

Hi Mikko!

You are right; it's not the same thing.

I'm trying to be practical here. libpaper is a Debian package, and the similar Debian bug http://bugs.debian.org/376350 is almost 7 years old now. It appears to be highly unlikely that Debian will make the change you would like to see.

My conclusion is that we'd better accept for now that there are two parallel ways to deal with paper size settings. So now in Ubuntu 13.04, when a user sets the regional formats via Language Support, both are updated. It means that the users will no longer experience the confusing behaviour in this bug description.

So I thought it was a good idea to close this bug and move on. But if you still disagree, I can reopen it. Please let me know.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.