1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PRINTING_UNITS_H_
6 #define PRINTING_UNITS_H_
8 #include "base/component_export.h"
9 #include "build/build_config.h"
13 // Length of an inch in 0.001mm unit.
14 constexpr int kMicronsPerInch = 25400;
16 // A micron is a thousandth of a mm.
17 constexpr int kMicronsPerMm = 1000;
19 // Length of a PWG unit in 0.001mm unit.
20 constexpr int kMicronsPerPwgUnit = kMicronsPerMm / 100;
22 // Mil is a thousandth of an inch.
23 constexpr float kMicronsPerMil = 25.4f;
24 constexpr int kMilsPerInch = 1000;
26 // Length of an inch in CSS's 1pt unit.
27 // http://dev.w3.org/csswg/css3-values/#absolute-length-units-cm-mm.-in-pt-pc
28 constexpr int kPointsPerInch = 72;
30 // Length of an inch in CSS's 1px unit.
31 // http://dev.w3.org/csswg/css3-values/#the-px-unit
32 constexpr int kPixelsPerInch = 96;
35 constexpr int kDefaultMacDpi = 72;
36 #endif // BUILDFLAG(IS_MAC)
38 // DPI used for Save to PDF. Also used as the default DPI in various use cases
39 // where there is no specified DPI.
40 constexpr int kDefaultPdfDpi = 300;
42 // LETTER: 8.5 x 11 inches
43 constexpr float kLetterWidthInch = 8.5f;
44 constexpr float kLetterHeightInch = 11.0f;
46 // LEGAL: 8.5 x 14 inches
47 constexpr float kLegalWidthInch = 8.5f;
48 constexpr float kLegalHeightInch = 14.0f;
50 // A4: 8.27 x 11.69 inches
51 constexpr float kA4WidthInch = 8.27f;
52 constexpr float kA4HeightInch = 11.69f;
54 // A3: 11.69 x 16.54 inches
55 constexpr float kA3WidthInch = 11.69f;
56 constexpr float kA3HeightInch = 16.54f;
58 // Converts from one unit system to another using integer arithmetics.
59 COMPONENT_EXPORT(PRINTING_BASE)
60 int ConvertUnit(float value, int old_unit, int new_unit);
62 // Converts from one unit system to another using floats.
63 COMPONENT_EXPORT(PRINTING_BASE)
64 float ConvertUnitFloat(float value, float old_unit, float new_unit);
66 } // namespace printing
68 #endif // PRINTING_UNITS_H_