[go: nahoru, domu]

blob: 24a416a66cc4ca8f370d619eb09bb8b4c00f4ad5 [file] [log] [blame]
Avi Drissmandb497b32022-09-15 19:47:281// Copyright 2011 The Chromium Authors
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
maruel@chromium.org4ae30d082009-02-20 17:55:555#ifndef PRINTING_UNITS_H_
6#define PRINTING_UNITS_H_
initial.commit09911bf2008-07-26 23:55:297
Alan Screen9347cae2021-04-27 18:11:248#include "base/component_export.h"
Andy Phanf864aac2023-02-22 00:12:299#include "build/build_config.h"
darin@chromium.org69f5b1e62011-09-01 06:34:0410
initial.commit09911bf2008-07-26 23:55:2911namespace printing {
12
Lei Zhangd11ab162018-06-26 04:28:5013// Length of an inch in 0.001mm unit.
14constexpr int kMicronsPerInch = 25400;
initial.commit09911bf2008-07-26 23:55:2915
Andy Phan24b783d2023-01-04 17:43:4516// A micron is a thousandth of a mm.
17constexpr int kMicronsPerMm = 1000;
18
Andy Phan37fb8722023-02-01 19:22:2519// Length of a PWG unit in 0.001mm unit.
20constexpr int kMicronsPerPwgUnit = kMicronsPerMm / 100;
21
Vladislav Kuzkokove2199102018-02-20 16:25:1322// Mil is a thousandth of an inch.
23constexpr float kMicronsPerMil = 25.4f;
24constexpr int kMilsPerInch = 1000;
25
hamaji@chromium.org4ebf5d12010-06-28 09:46:0026// 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
Daniel Hosseiniand8f4bc72019-12-16 20:13:1728constexpr int kPointsPerInch = 72;
hamaji@chromium.org4ebf5d12010-06-28 09:46:0029
30// Length of an inch in CSS's 1px unit.
31// http://dev.w3.org/csswg/css3-values/#the-px-unit
Daniel Hosseiniand8f4bc72019-12-16 20:13:1732constexpr int kPixelsPerInch = 96;
hamaji@chromium.org4ebf5d12010-06-28 09:46:0033
Andy Phanf864aac2023-02-22 00:12:2934#if BUILDFLAG(IS_MAC)
35constexpr int kDefaultMacDpi = 72;
36#endif // BUILDFLAG(IS_MAC)
37
Lei Zhang53fefd82023-06-06 01:24:1138// DPI used for Save to PDF. Also used as the default DPI in various use cases
39// where there is no specified DPI.
Daniel Hosseiniand8f4bc72019-12-16 20:13:1740constexpr int kDefaultPdfDpi = 300;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2941
42// LETTER: 8.5 x 11 inches
Daniel Hosseiniand8f4bc72019-12-16 20:13:1743constexpr float kLetterWidthInch = 8.5f;
44constexpr float kLetterHeightInch = 11.0f;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2945
46// LEGAL: 8.5 x 14 inches
Daniel Hosseiniand8f4bc72019-12-16 20:13:1747constexpr float kLegalWidthInch = 8.5f;
48constexpr float kLegalHeightInch = 14.0f;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2949
50// A4: 8.27 x 11.69 inches
Daniel Hosseiniand8f4bc72019-12-16 20:13:1751constexpr float kA4WidthInch = 8.27f;
52constexpr float kA4HeightInch = 11.69f;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2953
54// A3: 11.69 x 16.54 inches
Daniel Hosseiniand8f4bc72019-12-16 20:13:1755constexpr float kA3WidthInch = 11.69f;
56constexpr float kA3HeightInch = 16.54f;
vitalybuka@chromium.org4c9054b2013-11-04 18:34:2957
initial.commit09911bf2008-07-26 23:55:2958// Converts from one unit system to another using integer arithmetics.
Alan Screen04f4dfe2021-04-29 07:05:2559COMPONENT_EXPORT(PRINTING_BASE)
Xianzhu Wang805d7452022-01-19 06:55:3360int ConvertUnit(float value, int old_unit, int new_unit);
initial.commit09911bf2008-07-26 23:55:2961
Xianzhu Wang805d7452022-01-19 06:55:3362// Converts from one unit system to another using floats.
Alan Screen04f4dfe2021-04-29 07:05:2563COMPONENT_EXPORT(PRINTING_BASE)
Xianzhu Wang805d7452022-01-19 06:55:3364float ConvertUnitFloat(float value, float old_unit, float new_unit);
aayushkumar@chromium.org55b23a02011-08-17 23:09:3665
initial.commit09911bf2008-07-26 23:55:2966} // namespace printing
67
maruel@chromium.org4ae30d082009-02-20 17:55:5568#endif // PRINTING_UNITS_H_