]> git.lyx.org Git - lyx.git/blobdiff - src/FontInfo.C
fix typo that put too many include paths for most people
[lyx.git] / src / FontInfo.C
index 03e00a7d4077c716ab495214a41e3ab941859b6b..c9dd2e1839010d434723cf08a355c613dd9deff4 100644 (file)
@@ -1,32 +1,33 @@
 /* This file is part of
- * ====================================================== 
- * 
+ * ======================================================
+ *
  *           LyX, The Document Processor
- *      
+ *
  *         Copyright 1997 Asger Alstrup
  *           and the LyX Team.
  *
  * ====================================================== */
 
 #include <config.h>
-#include <cmath>       // fabs()
 
 #ifdef __GNUG__
-#pragma implementation "FontInfo.h"
+#pragma implementation
 #endif
 
 #include "FontInfo.h"
 #include "debug.h"
 #include "lyxrc.h"     // lyxrc.use_scalable_fonts
+
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
+
 #include "frontends/GUIRunTime.h"
 
+#include <cmath>       // abs()
+
 using std::endl;
+using std::abs;
 
-#ifndef CXX_GLOBAL_CSTD
-using std::fabs;
-#endif
 
 /// Load font close to this size
 string const FontInfo::getFontname(int size)
@@ -44,8 +45,8 @@ string const FontInfo::getFontname(int size)
                        lyxerr[Debug::FONT] << "Exact font match with\n"
                                            << strings[i] << endl;
                        return strings[i];
-               } else if (fabs(sizes[i] - size - 0.1) < error) {
-                       error = fabs(sizes[i] - size - 0.1);
+               } else if (abs(sizes[i] - size - 0.1) < error) {
+                       error = abs(sizes[i] - size - 0.1);
                        closestind = i;
                }
        }
@@ -66,13 +67,13 @@ string const FontInfo::getFontname(int size)
 
        // We use the closest match
        lyxerr[Debug::FONT] << "Using closest font match to get size "
-                           << size 
+                           << size
                            << " with\n" << strings[closestind] << endl;
        return strings[closestind];
 }
 
 
-/// Build newly sized font string 
+/// Build newly sized font string
 string const FontInfo::resize(string const & font, int size) const
 {
        string ret(font);
@@ -98,7 +99,6 @@ string const FontInfo::resize(string const & font, int size) const
 /// Set new pattern
 void FontInfo::setPattern(string const & pat)
 {
-       release();
        init();
        pattern = pat;
 }
@@ -111,7 +111,7 @@ void FontInfo::query()
                return;
 
        if (pattern.empty()) {
-               lyxerr << "Can not use empty font name for font query."
+               lyxerr << "Cannot use empty font name for font query."
                       << endl;
                queried = true;
                return;
@@ -125,15 +125,16 @@ void FontInfo::query()
        if (list == 0) {
                // No fonts matched
                scalable = false;
-               sizes = 0;
+               sizes.reset();
        } else {
-               release();
-               sizes = new int[matches];
-               strings = new string[matches];
+               sizes.reset(new int[matches]);
+               strings.reset(new string[matches]);
 
                // We have matches. Run them through
                for (int i = 0; i < matches; ++i) {
                        string name(list[i]);
+                       lyxerr[Debug::FONT] << "match #" << i << " "
+                                           << name << endl;
                        sizes[i] = lyx::atoi(token(name, '-', 7));
                        strings[i] = name;
                        if (sizes[i] == 0) {
@@ -151,24 +152,10 @@ void FontInfo::query()
 
 void FontInfo::init()
 {
-       sizes = 0;
-       strings = 0;
+       sizes.reset();
+       strings.reset();
        matches = 0;
        queried = false;
        scalable = false;
        scaleindex = -1;
 }
-
-
-/// Release allocated stuff
-void FontInfo::release()
-{
-       if (sizes) {
-               delete [] sizes;
-               sizes = 0;
-       }
-       if (strings) {
-               delete [] strings;
-               strings = 0;
-       }
-}