4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Abdelrazak Younes
9 * Full author contact details are available in file CREDITS.
12 #ifndef QT4_FONT_METRICS_H
13 #define QT4_FONT_METRICS_H
15 #include "frontends/FontMetrics.h"
17 #include "support/docstring.h"
19 #include <QFontMetrics>
26 class GuiFontMetrics: public FontMetrics
30 GuiFontMetrics(QFont const & font);
31 GuiFontMetrics(QFont const & font, QFont const & smallcaps_font);
33 virtual ~GuiFontMetrics() {}
35 virtual int maxAscent() const;
36 virtual int maxDescent() const;
37 virtual Dimension const defaultDimension() const;
38 virtual int width(char_type c) const;
39 virtual int ascent(char_type c) const;
40 virtual int descent(char_type c) const;
41 virtual int lbearing(char_type c) const;
42 virtual int rbearing(char_type c) const;
43 virtual int width(docstring const & s) const;
44 virtual int signedWidth(docstring const & s) const;
45 virtual Dimension const dimension(char_type c) const;
47 virtual void rectText(docstring const & str,
51 virtual void buttonText(docstring const & str,
56 int width(QString const & str) const;
59 int smallcapsWidth(char_type c) const;
61 /// Metrics on the font
62 QFontMetrics metrics_;
63 QFontMetrics smallcaps_metrics_;
65 bool smallcaps_shape_;
67 /// Cache of char widths
68 mutable QHash<char_type, int> width_cache_;
70 struct AscendDescend {
74 /// Cache of char ascends and descends
75 mutable QHash<char_type, AscendDescend> metrics_cache_;
76 /// fill in \c metrics_cache_ at specified value.
77 AscendDescend const fillMetricsCache(char_type) const;
79 /// Cache of char right bearings
80 mutable QHash<char_type, int> rbearing_cache_;
83 } // namespace frontend
86 #endif // QT4_FONT_METRICS_H