4 * Copyright 1995-2002 the LyX Team
5 * Read the file COPYING
8 * \author John Levon <moz@compsoc.man.ac.uk>
11 #ifndef FONT_METRICS_H
12 #define FONT_METRICS_H
19 * A namespace holding helper functions for determining
20 * the screen dimensions of fonts.
22 * The geometry is the standard typographical geometry,
25 * --------------+------------------<maxAscent
27 * <-------> (right bearing)
31 * origin>____ | oo oo | oo oo
33 * --------------+---ooooo--|--oooo-<baseline
36 * descent>______| oooo |
38 * --------------+----------+-------<maxDescent
41 namespace font_metrics {
42 /// return the maximum ascent of the font
43 int maxAscent(LyXFont const & f);
44 /// return the maximum descent of the font
45 int maxDescent(LyXFont const & f);
46 /// return the ascent of the char in the font
47 int ascent(char c, LyXFont const & f);
48 /// return the descent of the char in the font
49 int descent(char c, LyXFont const & f);
50 /// return the left bearing of the char in the font
51 int lbearing(char c, LyXFont const & f);
52 /// return the right bearing of the char in the font
53 int rbearing(char c, LyXFont const & f);
54 /// return the width of the string in the font
55 int width(char const * s, size_t n, LyXFont const & f);
56 /// return the width of the char in the font
57 inline int width(char c, LyXFont const & f) {
58 return width(&c, 1, f);
60 /// return the width of the string in the font
61 inline int width(string const & s, LyXFont const & f) {
62 if (s.empty()) return 0;
63 return width(s.data(), s.length(), f);
66 int signedWidth(string const & s, LyXFont const & f);
68 * fill in width,ascent,descent with the values for the
69 * given string in the font.
71 void rectText(string const & str, LyXFont const & font,
76 * fill in width,ascent,descent with the values for the
77 * given string in the font for a button.
79 void buttonText(string const & str, LyXFont const & font,
85 #endif // FONT_METRICS_H