]> git.lyx.org Git - lyx.git/blob - src/frontends/font_metrics.h
fix tooltips in toolbar
[lyx.git] / src / frontends / font_metrics.h
1 // -*- C++ -*-
2 /**
3  * \file font_metrics.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author unknown
8  * \author John Levon <moz@compsoc.man.ac.uk>
9  */
10
11 #ifndef FONT_METRICS_H
12 #define FONT_METRICS_H
13
14 #include "LString.h"
15
16 class LyXFont;
17
18 /**
19  * A namespace holding helper functions for determining
20  * the screen dimensions of fonts.
21  *
22  * The geometry is the standard typographical geometry,
23  * as follows :
24  *                                                                
25  * --------------+------------------<maxAscent
26  *               |          |
27  *               <-------> (right bearing)
28  *               <-> (left bearing)
29  * char ascent>___          |
30  *               ^   oooo   |  oooo              
31  *   origin>____ |  oo  oo  | oo  oo             
32  *              \|  oo  oo  | oo  oo             
33  * --------------+---ooooo--|--oooo-<baseline  
34  *               |      oo  |                 
35  * char          |  oo  oo  |                
36  * descent>______|   oooo   |                
37  *               <-  width ->
38  * --------------+----------+-------<maxDescent
39  *  
40  */
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);
59         }
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);
64         }
65         /// FIXME ??
66         int signedWidth(string const & s, LyXFont const & f);
67         /** 
68          * fill in width,ascent,descent with the values for the
69          * given string in the font.
70          */
71         void rectText(string const & str, LyXFont const & font,
72                 int & width, 
73                 int & ascent, 
74                 int & descent);
75         /** 
76          * fill in width,ascent,descent with the values for the
77          * given string in the font for a button.
78          */
79         void buttonText(string const & str, LyXFont const & font,
80                 int & width, 
81                 int & ascent, 
82                 int & descent);
83 }
84
85 #endif // FONT_METRICS_H