Jean-Marc Lasgouttes wrote:
If we can support Win9x, we should. Isn't there some kind way to fall
back to AddFontResource when it is the only one available?

Anyway Joost, I'll let you decide.

Let's not make things too complicated and go for AddFontResource and RemoveFontResource. The attached patch now also includes the second part. I tested it, the fonts are loaded correctly and the files are not locked anymore after closing LyX.

If you agree, can you put this in 1.4 and 1.5 (both qt3 and qt4)? I think it's the final thing to get the new installer to work.

Joost
Index: src/frontends/qt2/qfont_loader.C
===================================================================
--- frontends/qt2/qfont_loader.C        (revision 13844)
+++ frontends/qt2/qfont_loader.C        (working copy)
@@ -51,6 +51,18 @@
 #include <ApplicationServices/ApplicationServices.h>
 #endif
 
+#ifdef Q_WS_WIN
+#include "windows.h"
+#include "support/os.h"
+#include "support/package.h"
+#include "support/path.h"
+using lyx::support::AddName;
+using lyx::support::AddPath;
+using lyx::support::package;
+namespace os = lyx::support::os;
+string const win_fonts_truetype[] = {"cmex10", "cmmi10", "cmr10", "cmsy10",
+       "eufm10", "msam10", "msbm10", "wasy10"};
+#endif
 
 void FontLoader::initFontPath()
 {
@@ -81,8 +93,36 @@
        if (err)
                lyxerr << "FMActivateFonts err = " << err << endl;
 #endif
+
+#ifdef Q_WS_WIN
+       // Windows only: Add BaKoMa TrueType font resources
+
+       string const fonts_dir = AddPath(package().system_support(), "fonts");
+       string font_current;            
+       
+       for(int i=0; i < (sizeof(win_fonts_truetype) / 
sizeof(*win_fonts_truetype)); i++)
+       {
+               font_current = os::external_path(AddName(fonts_dir, 
win_fonts_truetype[i] + ".ttf"));
+               AddFontResource(font_current.c_str());
+       }
+#endif
 }
 
+FontLoader::~FontLoader() {
+#ifdef Q_WS_WIN
+       // Windows only: Remove BaKoMa TrueType font resources
+
+       string const fonts_dir = AddPath(package().system_support(), "fonts");
+       string font_current;            
+       
+       for(int i=0; i < (sizeof(win_fonts_truetype) / 
sizeof(*win_fonts_truetype)); i++)
+       {
+               font_current = os::external_path(AddName(fonts_dir, 
win_fonts_truetype[i] + ".ttf"));
+               RemoveFontResource(font_current.c_str());
+       }
+#endif
+}
+
 namespace {
 
 struct symbol_font {
Index: src/frontends/qt2/qfont_loader.h
===================================================================
--- frontends/qt2/qfont_loader.h        (revision 13844)
+++ frontends/qt2/qfont_loader.h        (working copy)
@@ -55,6 +55,9 @@
 public:
        ///
        FontLoader();
+       
+       /// Destructor
+       ~FontLoader();
 
        /// Update fonts after zoom, dpi, font names, or norm change
        void update();

Reply via email to