KD Reports API Documentation  2.0
KDReportsFontScaler_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Reports library.
4 **
5 ** SPDX-FileCopyrightText: 2007-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDReports OR LicenseRef-KDAB-KDReports-US
8 **
9 ** Licensees holding valid commercial KD Reports licenses may use this file in
10 ** accordance with the KD Reports Commercial License Agreement provided with
11 ** the Software.
12 **
13 ** Contact info@kdab.com if any conditions of this licensing are not clear to you.
14 **
15 ****************************************************************************/
16 
17 #ifndef FONTSCALER_P_H
18 #define FONTSCALER_P_H
19 
20 #include "KDReportsGlobal.h"
21 #include <QFont>
22 #include <QFontMetricsF>
23 
24 //
25 // W A R N I N G
26 // -------------
27 //
28 // This file is not part of the KD Reports API. It exists purely as an
29 // implementation detail. This header file may change from version to
30 // version without notice, or even be removed.
31 //
32 // We mean it.
33 //
34 //
35 
36 // Enable this to get debug output about the layouting
37 // (font scaling, table layout, spreadsheet layout)
38 //#define DEBUG_LAYOUT
39 
40 namespace KDReports {
41 
42 class KDREPORTS_EXPORT FontScaler
43 {
44 public:
45  explicit FontScaler(const QFont &initialFont);
46 
47  void setFontAndScalingFactor(const QFont &font, qreal scalingFactor);
48 
49  void setFactorForHeight(qreal wantedHeight);
50  void setFactorForWidth(qreal wantedFactor, const QString &sampleText);
51  void applyAdditionalScalingFactor(qreal factor);
52 
53  QFont font() const { return m_font; }
54  QFontMetricsF fontMetrics() const { return m_fontMetrics; }
55  qreal scalingFactor() const { return m_scalingFactor; }
56  QFontMetricsF initialFontMetrics() const { return m_initialFontMetrics; }
57  qreal textWidth(const QString &text) const;
58 
59 private:
60  QFont m_font;
61  QFontMetricsF m_fontMetrics;
62  QFontMetricsF m_initialFontMetrics;
63  qreal m_scalingFactor;
64 };
65 
66 }
67 
68 #endif /* FONTSCALER_P_H */
KDReportsGlobal.h
KDREPORTS_EXPORT
#define KDREPORTS_EXPORT
Definition: KDReportsGlobal.h:29
KDReports
Definition: KDReportsAbstractReportLayout_p.h:30

© 2007-2021 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-reports/
Generated on Sat Jan 8 2022 02:38:32 for KD Reports API Documentation by doxygen 1.8.17