]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/qt_helpers.C
lyxrc.*_font_foundry
[lyx.git] / src / frontends / qt2 / qt_helpers.C
1 /**
2  * \file qt_helpers.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Dekel Tsur
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "qt_helpers.h"
18
19 #include <qglobal.h>
20
21
22 string makeFontName(string const & family, string const & foundry)
23 {
24         if (foundry.empty())
25                 return family;
26 #if QT_VERSION  >= 300
27         return family + " [" + foundry + ']';
28 #else
29         return foundry + '-' + family;
30 #endif
31 }
32
33
34 pair<string,string> parseFontName(string const & name)
35 {
36 #if QT_VERSION  >= 300
37         string::size_type const idx = name.find('[');
38         if (idx == string::npos || idx == 0)
39                 return make_pair(name, string());
40         return make_pair(name.substr(0, idx - 1),
41                          name.substr(idx + 1, name.size() - idx - 2));
42 #else
43         string::size_type const idx = name.find('-');
44         if (idx == string::npos || idx == 0)
45                 return make_pair(name, string());
46         return make_pair(name.substr(idx + 1),
47                          name.substr(0, idx));
48 #endif
49 }