]> git.lyx.org Git - features.git/commitdiff
* src/frontends/qt3/qfontloader.C (initFontPath, ~FontLoader):
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 20 May 2006 08:21:58 +0000 (08:21 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 20 May 2006 08:21:58 +0000 (08:21 +0000)
* src/frontends/qt4/qfontloader.C (initFontPath, ~FontLoader): add fonts in
lyxdir/fonts to system fonts in windows; remove them in destructor.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13877 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt3/qfont_loader.C
src/frontends/qt3/qfont_loader.h
src/frontends/qt4/qfont_loader.C
src/frontends/qt4/qfont_loader.h

index 1ca348bb698a98adfb75ad245a00f16ff08a57fe..04805c0c89bb116c6ac431bf6a446357adc721da 100644 (file)
@@ -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 9c52c0c996e24ae83df13ce82cfc03779d6b8fca..3a03468d0c19574c819cc83041f280c7b32275f4 100644 (file)
@@ -55,6 +55,9 @@ class FontLoader {
 public:
        ///
        FontLoader();
+       
+       /// Destructor
+       ~FontLoader();
 
        /// Update fonts after zoom, dpi, font names, or norm change
        void update();
index a822680b47fbfb229fee86f0b7a0fdfadf143582..f11bec325c79062abce16736c6524f02850aa319 100644 (file)
@@ -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 ef7d03cde498c5c6e94fb2e91b079ae723d72be5..2e782267a451516c223862acb6e889f0629609a0 100644 (file)
@@ -55,6 +55,9 @@ class FontLoader {
 public:
        ///
        FontLoader();
+       
+       /// Destructor
+       ~FontLoader();
 
        /// Update fonts after zoom, dpi, font names, or norm change
        void update();