]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/qfont_loader.h
fix math fonts with LyX/Mac
[lyx.git] / src / frontends / qt2 / qfont_loader.h
index 42c508e1811f84f7a81d1999c7dd1df33707da87..73a0f4e4279085289fa6aa2f34f022a98b230ffe 100644 (file)
@@ -1,26 +1,22 @@
 // -*- C++ -*-
 /**
  * \file qfont_loader.h
- * Copyright 1997 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author John Levon <moz@compsoc.man.ac.uk>
+ * \author John Levon
+ *
+ * Full author contact details are available in file CREDITS.
  */
 
 #ifndef QFONTLOADER_H
-#define QFONTLOADER_H 
+#define QFONTLOADER_H
+
 
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include <map>
 
-#include <config.h>
-#include <boost/smart_ptr.hpp>
+#include "encoding.h"
 #include "lyxfont.h"
-#include "font_loader.h"
-#include "LString.h"
 
 #include <qfont.h>
 #include <qfontmetrics.h>
@@ -33,24 +29,31 @@ class qfont_loader {
 public:
        qfont_loader();
 
-       virtual ~qfont_loader();
+       ~qfont_loader();
 
        /// update fonts after zoom, dpi, font names, or norm change
-       virtual void update();
+       void update();
 
        /// do we have anything matching?
-       virtual bool available(LyXFont const & f);
+       bool available(LyXFont const & f);
+
        /// get the QFont for this LyXFont
-       QFont const & get(LyXFont const & f) {
-               return getfontinfo(f)->font;
-       }
+       QFont const & get(LyXFont const & f);
 
        /// get the QFont metrics for this LyXFont
        QFontMetrics const & metrics(LyXFont const & f) {
                return getfontinfo(f)->metrics;
        }
 
+       /// return pixel width for the given unicode char
+       int charwidth(LyXFont const & f, Uchar val);
+
+       /// Called before QApplication is initialized
+       static void initFontPath();
+       
+       /// Called the first time when available() can't load a symbol font
+       static void addToFontPath();
+
 private:
        /// hold info about a particular font
        struct font_info {
@@ -60,15 +63,19 @@ private:
                QFont font;
                /// metrics on the font
                QFontMetrics metrics;
+
+               typedef std::map<Uchar, int> WidthCache;
+               /// cache of char widths
+               WidthCache widthcache;
        };
+
        /// get font info (font + metrics) for the given LyX font. Does not fail.
-       font_info const * getfontinfo(LyXFont const & f);
+       font_info * getfontinfo(LyXFont const & f);
+
        /// BUTT ugly !
-       boost::scoped_ptr<font_info> fontinfo_[LyXFont::NUM_FAMILIES][2][4][10]; 
+       font_info * fontinfo_[LyXFont::NUM_FAMILIES][2][4][10];
 };
 
 extern qfont_loader fontloader;
+
 #endif // QFONT_LOADER_H