]> git.lyx.org Git - lyx.git/blobdiff - src/FontInfo.h
minipage width compatibility fix
[lyx.git] / src / FontInfo.h
index 450c76c44a9bf4947a96722bcddbfe85240ef7f8..7f4af1d4c7e574953a344c1fc63cf212bacf68c1 100644 (file)
@@ -1,16 +1,16 @@
 // -*- C++ -*-
 /* This file is part of
  * ======================================================
- * 
+ *
  *           LyX, The Document Processor
- *      
+ *
  *           Copyright 1997 Asger Alstrup
  *           and the LyX Team.
  *
  * ====================================================== */
 
 #ifndef FONTINFO_H
-#define FONTINFO_H 
+#define FONTINFO_H
 
 #ifdef __GNUG__
 #pragma interface
 
 #include "LString.h"
 
+#include <boost/smart_ptr.hpp>
+
 /** This class manages a font.
-The idea is to create a FontInfo object with a font name pattern with a 
-wildcard at the size field. Then this object can host request for font-
-instances of any given size. If no exact match is found, the closest size
-is chosen instead. If the font is scalable, the flag lyxrc.use_scalable_fonts
-determines whether to allow scalable fonts to give an exact match. */
+    The idea is to create a FontInfo object with a font name pattern with a
+    wildcard at the size field. Then this object can host request for font-
+    instances of any given size. If no exact match is found, the closest size
+    is chosen instead. If the font is scalable, the flag
+    lyxrc.use_scalable_fonts determines whether to allow scalable fonts to
+    give an exact match.
+*/
 class FontInfo {
 public:
        ///
        FontInfo() { init(); }
 
        ///
-       FontInfo(string const & pat)
-       : pattern(pat) { init(); }
-
-       /// Destructor
-       ~FontInfo() { release(); }
+       explicit FontInfo(string const & pat)
+               : pattern(pat) { init(); }
 
        /// Does any font match our pattern?
        bool exist() {
@@ -49,23 +50,23 @@ public:
        }
 
        /// Get existing pattern
-       string getPattern() const { return pattern; }
+       string const & getPattern() const { return pattern; }
 
        /// Set new pattern
        void setPattern(string const & pat);
 
        /** Return full name of font close to this size.
          If impossible, result is the empty string */
-       string getFontname(int size);
+       string const getFontname(int size);
 private:
        /// Font pattern (with wildcard for size)
        string pattern;
 
        /// Available size list
-       int * sizes;
+       boost::scoped_array<int> sizes;
 
        /// Corresponding name list
-       string * strings;
+       boost::scoped_array<string> strings;
 
        /// Number of matches
        int matches;
@@ -80,22 +81,12 @@ private:
        int scaleindex;
 
        /// Initialize empty record
-       void init() {
-               sizes = 0;
-               strings = 0;
-               matches = 0;
-               queried = false;
-               scalable = false;
-               scaleindex = -1;
-       }
-
-       /// Release allocated stuff
-       void release();
+       void init();
 
        /// Ask X11 about this font pattern
        void query();
 
-       /// Build newly sized font string 
-       string resize(string const &, int size) const;
+       /// Build newly sized font string
+       string const resize(string const &, int size) const;
 };
 #endif