4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
10 * Full author contact details are available in file CREDITS.
13 #ifndef FONT_METRICS_H
14 #define FONT_METRICS_H
16 #include "support/std_string.h"
21 * A namespace holding helper functions for determining
22 * the screen dimensions of fonts.
24 * The geometry is the standard typographical geometry,
27 * --------------+------------------<maxAscent
29 * <-------> (right bearing)
33 * origin>____ | oo oo | oo oo
35 * --------------+---ooooo--|--oooo-<baseline
38 * descent>______| oooo |
40 * --------------+----------+-------<maxDescent
43 namespace font_metrics {
44 /// return the maximum ascent of the font
45 int maxAscent(LyXFont const & f);
46 /// return the maximum descent of the font
47 int maxDescent(LyXFont const & f);
48 /// return the ascent of the char in the font
49 int ascent(char c, LyXFont const & f);
50 /// return the descent of the char in the font
51 int descent(char c, LyXFont const & f);
52 /// return the left bearing of the char in the font
53 int lbearing(char c, LyXFont const & f);
54 /// return the right bearing of the char in the font
55 int rbearing(char c, LyXFont const & f);
56 /// return the width of the string in the font
57 int width(char const * s, size_t n, LyXFont const & f);
58 /// return the width of the char in the font
59 inline int width(char c, LyXFont const & f) {
60 return width(&c, 1, f);
62 /// return the width of the string in the font
63 inline int width(string const & s, LyXFont const & f) {
64 if (s.empty()) return 0;
65 return width(s.data(), s.length(), f);
68 int signedWidth(string const & s, LyXFont const & f);
70 * fill in width,ascent,descent with the values for the
71 * given string in the font.
73 void rectText(string const & str, LyXFont const & font,
78 * fill in width,ascent,descent with the values for the
79 * given string in the font for a button.
81 void buttonText(string const & str, LyXFont const & font,
87 #endif // FONT_METRICS_H