4 * Read the file COPYING
9 * Full author contact details are available in file CREDITS
12 #ifndef FONT_METRICS_H
13 #define FONT_METRICS_H
20 * A namespace holding helper functions for determining
21 * the screen dimensions of fonts.
23 * The geometry is the standard typographical geometry,
26 * --------------+------------------<maxAscent
28 * <-------> (right bearing)
32 * origin>____ | oo oo | oo oo
34 * --------------+---ooooo--|--oooo-<baseline
37 * descent>______| oooo |
39 * --------------+----------+-------<maxDescent
42 namespace font_metrics {
43 /// return the maximum ascent of the font
44 int maxAscent(LyXFont const & f);
45 /// return the maximum descent of the font
46 int maxDescent(LyXFont const & f);
47 /// return the ascent of the char in the font
48 int ascent(char c, LyXFont const & f);
49 /// return the descent of the char in the font
50 int descent(char c, LyXFont const & f);
51 /// return the left bearing of the char in the font
52 int lbearing(char c, LyXFont const & f);
53 /// return the right bearing of the char in the font
54 int rbearing(char c, LyXFont const & f);
55 /// return the width of the string in the font
56 int width(char const * s, size_t n, LyXFont const & f);
57 /// return the width of the char in the font
58 inline int width(char c, LyXFont const & f) {
59 return width(&c, 1, f);
61 /// return the width of the string in the font
62 inline int width(string const & s, LyXFont const & f) {
63 if (s.empty()) return 0;
64 return width(s.data(), s.length(), f);
67 int signedWidth(string const & s, LyXFont const & f);
69 * fill in width,ascent,descent with the values for the
70 * given string in the font.
72 void rectText(string const & str, LyXFont const & font,
77 * fill in width,ascent,descent with the values for the
78 * given string in the font for a button.
80 void buttonText(string const & str, LyXFont const & font,
86 #endif // FONT_METRICS_H