]> git.lyx.org Git - lyx.git/blobdiff - src/FontInfo.C
another pesky \#warning snuck in
[lyx.git] / src / FontInfo.C
index cfc7143588d7e832dac823a1b4b9a5d3b1eb77ea..a9117e6f946d7b7bb487afbfe4f9859392ea9224 100644 (file)
@@ -11,7 +11,8 @@
 
 #include <config.h>
 #include <cmath>       // fabs()
-#include <cstdlib>     // atoi()
+
+#include FORMS_H_LOCATION
 
 #ifdef __GNUG__
 #pragma implementation "FontInfo.h"
 #include "lyxrc.h"     // lyxrc.use_scalable_fonts
 #include "support/lstrings.h"
 
-extern LyXRC * lyxrc;
+using std::endl;
 
 /// Load font close to this size
-string FontInfo::getFontname(int size)
+string const FontInfo::getFontname(int size)
 {
        if (!exist())
                return string();
 
        int closestind = -1;
-       double error = 100000;
+       double error = 100000.0;
 
        for (int i = 0; i < matches; ++i) {
                if (sizes[i] == 0) {
@@ -46,7 +47,7 @@ string FontInfo::getFontname(int size)
                }
        }
 
-       if (scalable && lyxrc->use_scalable_fonts) {
+       if (scalable && lyxrc.use_scalable_fonts) {
                // We can use scalable
                string font = resize(strings[scaleindex], size);
                lyxerr[Debug::FONT] << "Using scalable font to get\n"
@@ -69,7 +70,7 @@ string FontInfo::getFontname(int size)
 
 
 /// Build newly sized font string 
-string FontInfo::resize(string const & font, int size) const
+string const FontInfo::resize(string const & font, int size) const
 {
        string ret(font);
        // Find the position of the size spec
@@ -113,7 +114,9 @@ void FontInfo::query()
                return;
        }
 
-       char ** list = XListFonts(fl_display, pattern.c_str(), 100, &matches);
+       char ** list = 0;
+       if (lyxrc.use_gui)
+               list = XListFonts(fl_get_display(), pattern.c_str(), 100, &matches);
 
        if (list == 0) {
                // No fonts matched
@@ -125,9 +128,9 @@ void FontInfo::query()
                strings = new string[matches];
 
                // We have matches. Run them through
-               for(int i = 0; i < matches; ++i) {
+               for (int i = 0; i < matches; ++i) {
                        string name(list[i]);
-                       sizes[i] = atoi(token(name, '-', 7).c_str());
+                       sizes[i] = lyx::atoi(token(name, '-', 7));
                        strings[i] = name;
                        if (sizes[i] == 0) {
                                if (scaleindex == -1) {
@@ -142,6 +145,17 @@ void FontInfo::query()
 }
 
 
+void FontInfo::init()
+{
+       sizes = 0;
+       strings = 0;
+       matches = 0;
+       queried = false;
+       scalable = false;
+       scaleindex = -1;
+}
+
+
 /// Release allocated stuff
 void FontInfo::release()
 {