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