-// -*- C++ -*-
/* This file is part of
* ======================================================
*
#include <config.h>
#include <cmath> // fabs()
-#include <cstdlib> // atoi()
#ifdef __GNUG__
#pragma implementation "FontInfo.h"
#include "debug.h"
#include "lyxrc.h" // lyxrc.use_scalable_fonts
#include "support/lstrings.h"
+#include "support/lyxlib.h"
+#include "frontends/GUIRunTime.h"
+using std::endl;
+
+#ifndef CXX_GLOBAL_CSTD
+using std::fabs;
+#endif
/// 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) {
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;
/// 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
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
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) {
}
+void FontInfo::init()
+{
+ sizes = 0;
+ strings = 0;
+ matches = 0;
+ queried = false;
+ scalable = false;
+ scaleindex = -1;
+}
+
+
/// Release allocated stuff
void FontInfo::release()
{