X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FFontInfo.C;h=e7eb8117c0b70570e380daa8d303e9912a7b7e53;hb=dff2911bda426ad439e6475f62183cedd7044801;hp=71cf6e054b32fef27c401e01f1fa83ef34e96fbe;hpb=27de1486ca34aaad446adb798d71a77d6f6304da;p=lyx.git diff --git a/src/FontInfo.C b/src/FontInfo.C index 71cf6e054b..e7eb8117c0 100644 --- a/src/FontInfo.C +++ b/src/FontInfo.C @@ -1,42 +1,48 @@ -// -*- C++ -*- /* This file is part of - * ====================================================== + * ====================================================== * * LyX, The Document Processor * - * Copyright (C) 1997 Asger Alstrup + * Copyright 1997 Asger Alstrup * and the LyX Team. * - *======================================================*/ + * ====================================================== */ #include -#include // fabs() -#include // atoi() +#include // fabs() #ifdef __GNUG__ #pragma implementation "FontInfo.h" #endif #include "FontInfo.h" -#include "error.h" +#include "debug.h" #include "lyxrc.h" // lyxrc.use_scalable_fonts -extern LyXRC * lyxrc; +#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 -LString FontInfo::getFontname(int size) +string const FontInfo::getFontname(int size) { if (!exist()) - return LString(); + return string(); int closestind = -1; - double error = 100000; + double error = 100000.0; - for (int i=0; iuse_scalable_fonts) { + if (scalable && (lyxrc.use_scalable_fonts || closestind == -1)) { // We can use scalable - LString font = resize(strings[scaleindex], size); - lyxerr.debug("Using scalable font to get\n" - + font, Error::FONT); + string const font = resize(strings[scaleindex], size); + lyxerr[Debug::FONT] << "Using scalable font to get\n" + << font << endl; return font; } // Did any fonts get close? if (closestind == -1) { - // No, and we are not allowed to use scalables, so... - return LString(); + // No, so... + return string(); } // We use the closest match - lyxerr.debug(LString("Using closest font match to get size ") + size - + " with\n" + strings[closestind], Error::FONT); + lyxerr[Debug::FONT] << "Using closest font match to get size " + << size + << " with\n" << strings[closestind] << endl; return strings[closestind]; } + /// Build newly sized font string -LString FontInfo::resize(LString 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 - int cut=0, before=0, after=0; - for (int i=0; i