>>>>> "Joost" == Joost Verburg <[EMAIL PROTECTED]> writes:

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

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

Here is my take on your patch (for 1.4 and 1.5). I changed the style
to match the rest of the code. I have no idea whether this compiles,
so I'd appreciate if someone could test it for me.

JMarc

Index: src/frontends/qt2/qfont_loader.C
===================================================================
--- src/frontends/qt2/qfont_loader.C	(revision 13875)
+++ src/frontends/qt2/qfont_loader.C	(working copy)
@@ -51,6 +51,19 @@ using std::string;
 #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"};
+const int num_fonts_truetype = sizeof(win_fonts_truetype) / sizeof(*win_fonts_truetype);
+#endif
 
 void FontLoader::initFontPath()
 {
@@ -81,6 +94,30 @@ void FontLoader::initFontPath()
 	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");
+	
+	for (int i = 0 ; i < num_fonts_truetype ; ++i) {
+		string const font_current = 
+			AddName(fonts_dir, win_fonts_truetype[i] + ".ttf");
+		AddFontResource(os::external_path(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");
+	
+	for(int i = 0 ; i < num_fonts_truetype ; ++i) {
+		string const font_current = 
+			AddName(fonts_dir, win_fonts_truetype[i] + ".ttf"));
+		RemoveFontResource(os::external_path(font_current).c_str());
+	}
+#endif
 }
 
 namespace {
Index: src/frontends/qt2/qfont_loader.h
===================================================================
--- src/frontends/qt2/qfont_loader.h	(revision 13875)
+++ src/frontends/qt2/qfont_loader.h	(working copy)
@@ -55,6 +55,9 @@ class FontLoader {
 public:
 	///
 	FontLoader();
+	
+	/// Destructor
+	~FontLoader();
 
 	/// Update fonts after zoom, dpi, font names, or norm change
 	void update();
Index: src/frontends/qt3/qfont_loader.C
===================================================================
--- src/frontends/qt3/qfont_loader.C	(revision 13875)
+++ src/frontends/qt3/qfont_loader.C	(working copy)
@@ -51,6 +51,19 @@ using std::string;
 #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"};
+const int num_fonts_truetype = sizeof(win_fonts_truetype) / sizeof(*win_fonts_truetype);
+#endif
 
 void FontLoader::initFontPath()
 {
@@ -81,6 +94,30 @@ void FontLoader::initFontPath()
 	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");
+	
+	for (int i = 0 ; i < num_fonts_truetype ; ++i) {
+		string const font_current = 
+			addName(fonts_dir, win_fonts_truetype[i] + ".ttf");
+		AddFontResource(os::external_path(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");
+	
+	for(int i = 0 ; i < num_fonts_truetype ; ++i) {
+		string const font_current = 
+			addName(fonts_dir, win_fonts_truetype[i] + ".ttf"));
+		RemoveFontResource(os::external_path(font_current).c_str());
+	}
+#endif
 }
 
 namespace {
Index: src/frontends/qt3/qfont_loader.h
===================================================================
--- src/frontends/qt3/qfont_loader.h	(revision 13875)
+++ src/frontends/qt3/qfont_loader.h	(working copy)
@@ -55,6 +55,9 @@ class FontLoader {
 public:
 	///
 	FontLoader();
+	
+	/// Destructor
+	~FontLoader();
 
 	/// Update fonts after zoom, dpi, font names, or norm change
 	void update();
Index: src/frontends/qt4/qfont_loader.C
===================================================================
--- src/frontends/qt4/qfont_loader.C	(revision 13875)
+++ src/frontends/qt4/qfont_loader.C	(working copy)
@@ -47,6 +47,19 @@ using std::string;
 #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"};
+const int num_fonts_truetype = sizeof(win_fonts_truetype) / sizeof(*win_fonts_truetype);
+#endif
 
 void FontLoader::initFontPath()
 {
@@ -77,6 +90,30 @@ void FontLoader::initFontPath()
 	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");
+	
+	for (int i = 0 ; i < num_fonts_truetype ; ++i) {
+		string const font_current = 
+			addName(fonts_dir, win_fonts_truetype[i] + ".ttf");
+		AddFontResource(os::external_path(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");
+	
+	for(int i = 0 ; i < num_fonts_truetype ; ++i) {
+		string const font_current = 
+			addName(fonts_dir, win_fonts_truetype[i] + ".ttf"));
+		RemoveFontResource(os::external_path(font_current).c_str());
+	}
+#endif
 }
 
 namespace {
Index: src/frontends/qt4/qfont_loader.h
===================================================================
--- src/frontends/qt4/qfont_loader.h	(revision 13875)
+++ src/frontends/qt4/qfont_loader.h	(working copy)
@@ -55,6 +55,9 @@ class FontLoader {
 public:
 	///
 	FontLoader();
+	
+	/// Destructor
+	~FontLoader();
 
 	/// Update fonts after zoom, dpi, font names, or norm change
 	void update();

Reply via email to