Difference between revisions of "DefaultPaperSize"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 161: Line 161:
 
     Kai 32      (130 mm x 185 mm)
 
     Kai 32      (130 mm x 185 mm)
 
     Kai 32 (big) (140 mm x 203 mm)
 
     Kai 32 (big) (140 mm x 203 mm)
 +
 +
If I was able to read it [http://www.ksrongya.com.cn/Article.asp?Action=View&ArticleID=28&Catalog=2 this page] might help, where the term 16开 is used frequently and 185x260 appears near it sometimes, though 195×270 does too, so its possibly a generic term for a 1/16 of a sheet, making the question what's the size of the parent of the hierarchy and in what native units is is measured.

Revision as of 08:43, 11 June 2009

Default Paper Size on Linux

In OpenOffice.org VCL has a concept of a default paper size for a printer, and most applications then have a parallel concept of a default paper size for pages in a documents.

The VCL paper size for a printer can be seen in the UI in file->printer settings->properties->paper size The Application paper size for a page can be seen in the UI in e.g. writer from format->page

The VCL paper size doesn't matter greatly as its overridden by most OpenOffice.org applications, only simple applications like Math have no page style to override it.

VCL Default Paper Size

On Linux this default paper size is determined in psprint/source/printer/printerinfomanager.cxx as PrinterInfoManager::initSystemDefaultPaper the algorithm is

  • ask paperconf if it exists
    • paperconf checks $PAPERSIZE as "Letter" vs "A4", falling back to the contents of the file at $PAPERCONF, falling back to the contents of /etc/papersize, falling back to a default of "Letter"
  • otherwise check LC_PAPER and use mapping one
  • otherwise check osl_getProcessLocale and use mapping one
    • osl_getProcessLocale ends up in sal/osl/unx/nlsupport.c taking the value of LC_CTYPE

mapping one

All locales are A4 except for: en_US, en_CA, fr_CA, en

Application Default Paper Size

The default paper size is derived effectively from DefaultLocale by SvxPaperInfo::GetDefaultSvxPaper in svx/source/items/paperinf.cxx using mapping two. DefaultLocale is set during first-start from

  • getLangFromEnvironment in i18npool/source/isolang/inunx.cxx
    • LC_ALL, LC_CTYPE, LANG

mapping two

All locales are A4 except for: en_US, en_CA, fr_CA, es_MX, es_VE

GTK

For comparison gtk has gtk_paper_size_get_default which takes this from the locale as well, using mapping three as a fallback when _NL_PAPER_WIDTH/_NL_PAPER_HEIGHT is not available (note that gtk only recognizes the A4 and Letter sizes from _NL_PAPER_WIDTH/_NL_PAPER_HEIGHT)

  • LC_PAPER, LC_MESSAGES (gtk/gtkpapersize.c)

mapping three

All locales are A4 except for: en_US, en_CA, es_PR, es_US

Other sources

While Wikipedia also agrees that only the US and Canada officially don't use A4 but that in Mexico, Colombia, Chile and the Philippines Letter is also commonly used. Meanwhile at Microsoft the list of Letter nations is, the US, Canada, Argentina, Brazil, Chile, Mexico, Venezuela and "Latin American countries".

glibc

While glibc currently lists the US, Canada and Puerto Rico as the only Letter using territories. With some oddities where en_US is Letter while es_US is A4, and en_CA is Letter while ik_CA and iu_CA are A4.

CLDR 1.6

At unicode.org the only locales for CLDR 1.6 listed as using Letter were the US and Canada. (Puerto Rico, Mexico, Venezuela were all listed as A4).

CLDR 1.7

For CLDR 1.7 there is a review (1710) underway that is likely to match this page

Summary

Mapping locales to page size is done inconsistently. In OOo we should at least have one place that does it, not two. And reconcile the locales that have Letter as an appropriate default. We should also agree that when taking a locale setting to use to look up a default paper size that we try through LC_PAPER first, using _NL_PAPER_WIDTH/_NL_PAPER_HEIGHT (as shown here), and then fallback to mapping a locale territory to a default according to best fallback mapping below in order of LANGUAGE, LC_ALL, LC_MESSAGES, LANG, en_US

paperconf's own default of using Letter as a final fallback sucks as most people use A4, ideally paperconf could be convinced to use the same mechanism in the absence of a override setting, which is what we now do in Fedora.

Probable Best Fallback Mapping

All others, A4 (including Brazil, Argentina)

Pulling PageSize from LC_PAPER

#include <stdio.h>
#include <locale.h>
#include <langinfo.h>

#define NL_PAPER_GET(x)         \
  ((union { char *string; unsigned int word; })nl_langinfo(x)).word

int main(int argc,char **argv)
{
  int w, h;

  setlocale (LC_PAPER, "");
  w = NL_PAPER_GET (_NL_PAPER_WIDTH);
  h = NL_PAPER_GET (_NL_PAPER_HEIGHT);
  printf ("height: %d\nwidth: %d\n", h, w);
  return 0;
}

This gives dimensions in rounded mm, e.g. with Letter getting recorded as 216mm x 279mm, while the accurate size of Letter is 215.9 × 279.4. So a conversion to rounded to whole mm is required to test for recognized page sizes.

Notes on Legal, Folio, German Legal Fanfold and Long Bond Paper

The Philippines has a paper size called "Long Bond Paper", also known locally as "Legal" which is 8.5" x 13". The US Legal size is 8.5" x 14", causing confusion in the Philippines. 8.5" x 13" is called "German Legal Fanfold" in the PPD specification, but some e.g. Microsoft call that size "Folio". Unfortunately for the "Folio" term, in the PPD spec it is a different size than this (210mm x 220mm, i.e. 8.27" x 13"), and so is another ambivalent term probably best to be avoided.

Notes on Windows Paper Sizes

The Windows Documentation has some confusion around the two different JIS and ISO B paper types.

   DMPAPER_B4        B4 (JIS) 250 x 354 mm
   DMPAPER_B5        B5 (JIS) 182 x 257 mm
   DMPAPER_ISO_B4    B4 (ISO) 250 x 353 mm
   DMPAPER_B6_JIS    B6 (JIS) 128 x 182 mm

DMPAPER_B5 is documented as JIS and the documented dimensions match that format, but DMPAPER_B4 is then documented as JIS but the documented dimensions match the ISO format B5 of 250 × 353 mm. Given the presence of DMPAPER_ISO_B4 and the absence of DMPAPER_B4_JIS I'll bet that it is really the JIS size of 257 x 364, which is backed up by the PPD Specification stating that the Microsoft DMPAPER_B4 size is 257x364 and by the Microsoft Word UI which lists B4 (JIS) with a width of 257x364.

Since writing the above, the windows documentation has been refreshed and moved and now matches the above findings.

Meanwhile:

   DMPAPER_ENV_B4    Envelope B4 250 x 353 mm
   DMPAPER_ENV_B5    Envelope B5 176 x 250 mm
   DMPAPER_ENV_B6    Envelope B6 176 x 125 mm

suggest that for some special reason B6 Envelopes are rotated 90 degrees from B6 paper size (125 x 176mm) while the other B sizes when used as Envelopes are not rotated. This time the PPD Specification agrees with MS and gives

   EnvISOB4    250 x 353    DMPAPER_ENV_B4
   EnvISOB5    176 x 250    DMPAPER_ENV_B5
   EnvISOB6    176 x 125    DMPAPER_ENV_B6

in contrast to:

   ISOB4    250 x 353    DMPAPER_ISO_B4
   ISOB5    176 x 250
   ISOB6    125 x 176

DMPAPER_ENV_B6 doesn't matter so us, so lets just accept that it signifies an envelope that is the same size as a rotated B6 paper size.

Turning our eyes to the Excel Documentation we have more confusion with the XlPaperSize enumation. Here we have...

   xlPaperA5    A5 (148 mm x 210 mm)
   xlPaperB4    B4 (250 mm x 354 mm)
   xlPaperB5    A5 (148 mm x 210 mm)

well what size is xlPaperB5 ? Is it truly ISO A5 (148 mm x 210 mm) like the comment says. Or might it be ISO B5, i.e. 176 × 250 mm. Or, seeing as the XlPaperSize enumeration has the same values as the DMPAPER values for all other values, are they actually the same values as DMPAPER_B4 and DMPAPER_B5, which we've earlier determined are JIS B4 and B5 sizes, and not ISO sizes at all. That's the most likely answer, i.e. the text is completely and totally wrong.

Notes on Kai Paper Sizes

There are three /Kai/ paper sizes in use in China. This documentation states their sizes as

   16 Kai      (184 mm x 260 mm)
   32 Kai      (130 mm x 184 mm)
   Big 32 Kai  (140 mm x 203 mm)

But (at the time of writing, 2009-06-11) the Papierformat de.wikipedia claims

   Kai 8       (260 mm x 370 mm)
   Kai 16      (185 mm x 260 mm)
   Kai 32      (130 mm x 185 mm)
   Kai 32 groß (140 mm x 203 mm)

This Konica Minolta magicolor 7450 printer technical guide agrees and gives

   Kai 16      (185 mm x 260 mm)
   Kai 32      (130 mm x 185 mm)

As does this page

   Kai 8        (260 mm x 370 mm)
   Kai 16       (185 mm x 260 mm)
   Kai 32       (130 mm x 185 mm)
   Kai 32 (big) (140 mm x 203 mm)

If I was able to read it this page might help, where the term 16开 is used frequently and 185x260 appears near it sometimes, though 195×270 does too, so its possibly a generic term for a 1/16 of a sheet, making the question what's the size of the parent of the hierarchy and in what native units is is measured.

Personal tools