bug-groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 0/2] Locale support in font's papersize definition


From: Michal Vyskocil
Subject: [PATCH 0/2] Locale support in font's papersize definition
Date: Tue, 27 Sep 2011 11:52:49 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Hallo,

Following patch add the new keyword locale to the font DESC file. In
this case groff will determine the paper size from locales, so it not
needs to be hard-coded in the random file (/etc/papersize, or DESC file
itself).

Unfortunately even if the task seems to be simple, I've found several
caveats, so my implementation looks hackish. However it seems to me
like the best one for groff.

What I did - first of all I used the glibc extension
nl_langinfo(_NL_PAPER_*), which can returns me the numbers
automatically. I would accept that this feature should not be available
on non-glibc systems, however the main reason for not using nl_langinfo
is the way how it's implemented in glibc.

Prototype looks like char *nl_langinfo(nl_item item), so it returns
pointer to char. However if you use _NL_PAPER_* function returns
unsigned int and Ulrich Drepper is convinced that's the correct way [1].
And even if I can solve it in C using the union magic, my C++-fu is too
poor for it. IOW I did not find any simple way how to use that in C++
program.

However in a meanwhile I've found the Default Paper Size on Linux [2] on
openoffice wiki, which explains all stuffs behind. After reading of it,
I saw two ways:

 1. use libpaper [3]
 2. hard-code the list of countries using letter into code like gtk does

Finally I've decided to use gtk-like way, because this won't add any
additional dependencies for groff and it's really simple to write that.
So I went through latest Territory-Language Information [4], wrote a
static list of countries using letter and wrote function int
is_letter(char* variable), which goes through country code in variable
and if it's in a list, returns 1. Then I added new entry into papersizes
array with a name locale.

At the moment only LC_PAPER is taken in account. However it might make a
sense that others variables should be queried as well, even if I'm not
sure which. Gtk uses LC_PAPER and LC_MESSAGES, I saw some attempts with
LC_MONETARY (this seems wrong to me) and the SUSE script updating
/etc/papersize use LC_PAPER, LANG and LC_ALL.

[1] http://www.cygwin.com/ml/libc-alpha/2001-04/msg00186.html
[2] http://wiki.services.openoffice.org/wiki/DefaultPaperSize
[3] http://packages.debian.org/source/lenny/libpaper
[4] 
http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/territory_language_information.html

Thanks for your feedback
Michal Vyskocil

Michal Vyskocil (2):
  locale support in papersize definition
  documentation for the locale keyword

 doc/groff.texinfo           |    5 +++--
 man/groff_font.man          |    6 ++++++
 src/include/paper.h         |    4 ++--
 src/libs/libgroff/paper.cpp |   42 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 53 insertions(+), 4 deletions(-)

-- zr
1.7.6.3

Attachment: pgpr5xjrOwGm4.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]