]> git.lyx.org Git - lyx.git/blobdiff - src/FontInfo.C
Fix crash when running lyx -dbg insets -e ...
[lyx.git] / src / FontInfo.C
index 95a936142f5600cdff673f1e3ce6968ca045665a..43aa03c5770277ea01e79389ef3b466c3b99ed97 100644 (file)
@@ -1,4 +1,3 @@
-// -*- C++ -*-
 /* This file is part of
  * ====================================================== 
  * 
@@ -12,8 +11,6 @@
 #include <config.h>
 #include <cmath>       // fabs()
 
-#include FORMS_H_LOCATION
-
 #ifdef __GNUG__
 #pragma implementation "FontInfo.h"
 #endif
 #include "debug.h"
 #include "lyxrc.h"     // lyxrc.use_scalable_fonts
 #include "support/lstrings.h"
+#include "frontends/GUIRunTime.h"
 
 using std::endl;
 
+#ifndef CXX_GLOBAL_CSTD
+using std::fabs;
+#endif
+
 /// Load font close to this size
 string const FontInfo::getFontname(int size)
 {
@@ -32,7 +34,7 @@ string const FontInfo::getFontname(int size)
                return string();
 
        int closestind = -1;
-       double error = 100000;
+       double error = 100000.0;
 
        for (int i = 0; i < matches; ++i) {
                if (sizes[i] == 0) {
@@ -49,7 +51,7 @@ string const FontInfo::getFontname(int size)
 
        if (scalable && lyxrc.use_scalable_fonts) {
                // We can use scalable
-               string font = resize(strings[scaleindex], size);
+               string const font = resize(strings[scaleindex], size);
                lyxerr[Debug::FONT] << "Using scalable font to get\n"
                                    << font << endl;
                return font;
@@ -116,7 +118,8 @@ void FontInfo::query()
 
        char ** list = 0;
        if (lyxrc.use_gui)
-               list = XListFonts(fl_display, pattern.c_str(), 100, &matches);
+               list = XListFonts(GUIRunTime::x11Display(), pattern.c_str(),
+                                 100, &matches);
 
        if (list == 0) {
                // No fonts matched
@@ -128,7 +131,7 @@ 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] = lyx::atoi(token(name, '-', 7));
                        strings[i] = name;