On Thu, Sep 06, 2007 at 08:29:33PM +0200, Andre Poenitz wrote: > On Thu, Sep 06, 2007 at 07:04:15PM +0200, Georg Baum wrote:
> > IMHO a real fix would put the font stuff in the frontend where it belongs. > > Then there would not be any link problems in client and tex2lyx. > > That's of course correct. Here are the patches for trunk and branch. Those with Qt 4.1, on *nix should register the fonts with fontconfig by themselves (or use the xft-fonts package), on windows should install the fonts. Who is not willing (or cannot) upgrade pays a small price but is still able to use lyx. There's no problem on Mac, where Qt 4.3 is already required, but someone should check that things actually work, as I cannot do it. -- Enrico
Index: src/LyX.cpp =================================================================== --- src/LyX.cpp (revision 20095) +++ src/LyX.cpp (working copy) @@ -450,9 +450,6 @@ int LyX::exec(int & argc, char * argv[]) return !final_success; } - // Force adding of font path _before_ Application is initialized - support::os::addFontResources(); - // Let the frontend parse and remove all arguments that it knows pimpl_->application_.reset(createApplication(argc, argv)); @@ -487,9 +484,6 @@ int LyX::exec(int & argc, char * argv[]) prepareExit(); - // Restore original font resources after Application is destroyed. - support::os::restoreFontResources(); - return exit_status; } Index: src/frontends/qt4/GuiFontLoader.cpp =================================================================== --- src/frontends/qt4/GuiFontLoader.cpp (revision 20095) +++ src/frontends/qt4/GuiFontLoader.cpp (working copy) @@ -21,8 +21,11 @@ #include "support/filetools.h" #include "support/lstrings.h" #include "support/Systemcall.h" +#include "support/Package.h" +#include "support/os.h" #include <qfontinfo.h> +#include <QFontDatabase> #include <boost/tuple/tuple.hpp> @@ -33,6 +36,9 @@ #endif using lyx::support::contains; +using lyx::support::package; +using lyx::support::addPath; +using lyx::support::addName; using std::endl; using std::make_pair; @@ -41,6 +47,12 @@ using std::pair; using std::vector; using std::string; +#if QT_VERSION >= 0x040200 +string const math_fonts[] = {"cmex10", "cmmi10", "cmr10", "cmsy10", + "eufm10", "msam10", "msbm10", "wasy10", "esint10"}; +int const num_math_fonts = sizeof(math_fonts) / sizeof(*math_fonts); +#endif + namespace lyx { namespace frontend { @@ -189,6 +201,24 @@ pair<QFont, bool> const getSymbolFont(st GuiFontLoader::GuiFontLoader() { +#if QT_VERSION >= 0x040200 + fontID = new int[num_math_fonts]; + + string const fonts_dir = + addPath(package().system_support().absFilename(), "fonts"); + + for (int i = 0 ; i < num_math_fonts; ++i) { + string const font_file = lyx::support::os::external_path( + addName(fonts_dir, math_fonts[i] + ".ttf")); + fontID[i] = QFontDatabase::addApplicationFont(toqstr(font_file)); + + LYXERR(Debug::FONT) << "Adding font " << font_file + << static_cast<const char *> + (fontID[i] < 0 ? " FAIL" : " OK") + << endl; + } +#endif + for (int i1 = 0; i1 < Font::NUM_FAMILIES; ++i1) for (int i2 = 0; i2 < 2; ++i2) for (int i3 = 0; i3 < 4; ++i3) @@ -197,6 +227,19 @@ GuiFontLoader::GuiFontLoader() } +GuiFontLoader::~GuiFontLoader() +{ +#if QT_VERSION >= 0x040200 + for (int i = 0 ; i < num_math_fonts; ++i) { + if (fontID[i] >= 0) + QFontDatabase::removeApplicationFont(fontID[i]); + } + + delete [] fontID; +#endif +} + + void GuiFontLoader::update() { for (int i1 = 0; i1 < Font::NUM_FAMILIES; ++i1) { Index: src/frontends/qt4/GuiFontLoader.h =================================================================== --- src/frontends/qt4/GuiFontLoader.h (revision 20095) +++ src/frontends/qt4/GuiFontLoader.h (working copy) @@ -48,7 +48,7 @@ public: GuiFontLoader(); /// Destructor - virtual ~GuiFontLoader() {} + ~GuiFontLoader(); virtual void update(); virtual bool available(Font const & f); @@ -74,6 +74,9 @@ public: } private: +#if QT_VERSION >= 0x040200 + int * fontID; +#endif /// BUTT ugly ! QLFontInfo * fontinfo_[Font::NUM_FAMILIES][2][4][10]; }; Index: src/support/os_cygwin.cpp =================================================================== --- src/support/os_cygwin.cpp (revision 20095) +++ src/support/os_cygwin.cpp (working copy) @@ -32,24 +32,6 @@ using std::string; using lyx::support::contains; -#ifdef X_DISPLAY_MISSING -#include "support/filetools.h" -#include "support/Package.h" -#include "support/Path.h" -using lyx::support::addName; -using lyx::support::addPath; -using lyx::support::package; - -// API definition for manually calling font functions on Windows 2000 and later -typedef int (WINAPI *FONTAPI)(LPCSTR, DWORD, PVOID); -#define FR_PRIVATE 0x10 - -// Names of TrueType fonts to load -string const win_fonts_truetype[] = {"cmex10", "cmmi10", "cmr10", "cmsy10", - "eufm10", "msam10", "msbm10", "wasy10", "esint10"}; -const int num_fonts_truetype = sizeof(win_fonts_truetype) / sizeof(*win_fonts_truetype); -#endif - namespace lyx { namespace support { @@ -294,59 +276,6 @@ bool autoOpenFile(string const & filenam win_path.c_str(), NULL, NULL, 1)) > 32; } - -void addFontResources() -{ -#ifdef X_DISPLAY_MISSING - // Windows only: Add BaKoMa TrueType font resources - string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); - - HMODULE hDLL = LoadLibrary("gdi32"); - FONTAPI pAddFontResourceEx = - (FONTAPI) GetProcAddress(hDLL, "AddFontResourceExA"); - - for (int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = to_local8bit(from_utf8(convert_path( - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"), - PathStyle(windows)))); - if (pAddFontResourceEx) { - // Windows 2000 and later: Use AddFontResourceEx - pAddFontResourceEx(font_current.c_str(), FR_PRIVATE, 0); - } else { - // Older Windows versions: Use AddFontResource - AddFontResource(font_current.c_str()); - } - } - FreeLibrary(hDLL); -#endif -} - - -void restoreFontResources() -{ -#ifdef X_DISPLAY_MISSING - // Windows only: Remove BaKoMa TrueType font resources - string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); - - HMODULE hDLL = LoadLibrary("gdi32"); - FONTAPI pRemoveFontResourceEx = (FONTAPI) GetProcAddress(hDLL, "RemoveFontResourceExA"); - - for(int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = to_local8bit(from_utf8(convert_path( - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"), - PathStyle(windows)))); - if (pRemoveFontResourceEx) { - // Windows 2000 and later: Use RemoveFontResourceEx - pRemoveFontResourceEx(font_current.c_str(), FR_PRIVATE, 0); - } else { - // Older Windows versions: Use RemoveFontResource - RemoveFontResource(font_current.c_str()); - } - } - FreeLibrary(hDLL); -#endif -} - } // namespace os } // namespace support } // namespace lyx Index: src/support/os_unix.cpp =================================================================== --- src/support/os_unix.cpp (revision 20095) +++ src/support/os_unix.cpp (working copy) @@ -13,19 +13,11 @@ #include <config.h> #include "support/os.h" -#include "debug.h" #ifdef __APPLE__ #include <Carbon/Carbon.h> -#include <ApplicationServices/ApplicationServices.h> -#elif defined(HAVE_FONTCONFIG_FONTCONFIG_H) -#include "support/filetools.h" -#include "support/Package.h" -#include <fontconfig/fontconfig.h> -using lyx::support::addPath; #endif -using std::endl; using std::string; @@ -200,52 +192,6 @@ bool autoOpenFile(string const & filenam #endif } - -void addFontResources() -{ -#ifdef __APPLE__ - CFBundleRef myAppBundle = CFBundleGetMainBundle(); - CFURLRef myAppResourcesURL, FontsURL; - FSRef fontDirRef; - FSSpec fontDirSpec; - CFStringRef filePath = CFStringCreateWithBytes(kCFAllocatorDefault, - (UInt8 *) "fonts", strlen("fonts"), - kCFStringEncodingISOLatin1, false); - - myAppResourcesURL = CFBundleCopyResourcesDirectoryURL(myAppBundle); - FontsURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault, - myAppResourcesURL, filePath, true); - if (lyxerr.debugging(Debug::FONT)) { - UInt8 buf[255]; - if (CFURLGetFileSystemRepresentation(FontsURL, true, buf, 255)) - lyxerr << "Adding Fonts directory: " << buf << endl; - } - CFURLGetFSRef (FontsURL, &fontDirRef); - OSStatus err = FSGetCatalogInfo (&fontDirRef, kFSCatInfoNone, - NULL, NULL, &fontDirSpec, NULL); - if (err) - lyxerr << "FSGetCatalogInfo err = " << err << endl; - err = FMActivateFonts (&fontDirSpec, NULL, NULL, - kFMLocalActivationContext); - if (err) - lyxerr << "FMActivateFonts err = " << err << endl; -#elif defined(HAVE_FONTCONFIG_FONTCONFIG_H) - // Register BaKoMa truetype fonts with fontconfig - string const fonts_dir = - addPath(package().system_support().absFilename(), "fonts"); - if (!FcConfigAppFontAddDir(0, (FcChar8 const *)fonts_dir.c_str())) - lyxerr << "Unable to register fonts with fontconfig." << endl; -#endif -} - - -void restoreFontResources() -{ -#if defined(HAVE_FONTCONFIG_FONTCONFIG_H) && !defined(__APPLE__) - FcConfigAppFontClear(0); -#endif -} - } // namespace os } // namespace support } // namespace lyx Index: src/support/os.h =================================================================== --- src/support/os.h (revision 20095) +++ src/support/os.h (working copy) @@ -109,19 +109,6 @@ bool canAutoOpenFile(std::string const & */ bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW); -/** General font utilities. - * FIXME: only MAC and WIN32 for now but it would be nice to convince - * fontconfig to do the same for linux. - */ - -/// Add fonts to the font subsystem, must be called before Application -/// is initialized. -void addFontResources(); - -/// Restore original font resources, must be called after Application -/// is destroyed. -void restoreFontResources(); - } // namespace os } // namespace support } // namespace lyx Index: src/support/os_win32.cpp =================================================================== --- src/support/os_win32.cpp (revision 20095) +++ src/support/os_win32.cpp (working copy) @@ -19,8 +19,6 @@ #include "support/lstrings.h" #include "support/filetools.h" #include "support/ExceptionMessage.h" -#include "support/Package.h" -#include "support/Path.h" #include "debug.h" #include "gettext.h" @@ -70,18 +68,6 @@ using std::string; using lyx::support::runCommand; using lyx::support::split; -using lyx::support::addName; -using lyx::support::addPath; -using lyx::support::package; - -// API definition for manually calling font functions on Windows 2000 and later -typedef int (WINAPI *FONTAPI)(LPCSTR, DWORD, PVOID); -#define FR_PRIVATE 0x10 - -// Names of TrueType fonts to load -string const win_fonts_truetype[] = {"cmex10", "cmmi10", "cmr10", "cmsy10", - "eufm10", "msam10", "msbm10", "wasy10", "esint10"}; -const int num_fonts_truetype = sizeof(win_fonts_truetype) / sizeof(*win_fonts_truetype); namespace lyx { @@ -407,54 +393,6 @@ bool autoOpenFile(string const & filenam to_local8bit(from_utf8(filename)).c_str(), NULL, NULL, 1)) > 32; } - -void addFontResources() -{ - // Windows only: Add BaKoMa TrueType font resources - string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); - - HMODULE hDLL = LoadLibrary("gdi32"); - FONTAPI pAddFontResourceEx = (FONTAPI) GetProcAddress(hDLL, "AddFontResourceExA"); - - for (int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"); - if (pAddFontResourceEx) { - // Windows 2000 and later: Use AddFontResourceEx for private font - pAddFontResourceEx(to_local8bit(from_utf8(external_path(font_current))).c_str(), FR_PRIVATE, 0); - } else { - // Older Windows versions: Use AddFontResource - AddFontResource(to_local8bit(from_utf8(external_path(font_current))).c_str()); - } - } - - FreeLibrary(hDLL); -} - - -void restoreFontResources() -{ - // Windows only: Remove BaKoMa TrueType font resources - string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); - - HMODULE hDLL = LoadLibrary("gdi32"); - FONTAPI pRemoveFontResourceEx = (FONTAPI) GetProcAddress(hDLL, "RemoveFontResourceExA"); - - for(int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"); - if (pRemoveFontResourceEx) { - // Windows 2000 and later: Use RemoveFontResourceEx for private font - pRemoveFontResourceEx(to_local8bit(from_utf8(external_path(font_current))).c_str(), FR_PRIVATE, 0); - } else { - // Older Windows versions: Use RemoveFontResource - RemoveFontResource(to_local8bit(from_utf8(external_path(font_current))).c_str()); - } - } - - FreeLibrary(hDLL); -} - } // namespace os } // namespace support } // namespace lyx Index: configure.ac =================================================================== --- configure.ac (revision 20095) +++ configure.ac (working copy) @@ -236,7 +236,7 @@ AC_LANG_POP(C) # some standard header files AC_HEADER_DIRENT AC_HEADER_MAJOR -AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h io.h process.h NewAPIs.h utime.h sys/utime.h fontconfig/fontconfig.h) +AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h io.h process.h NewAPIs.h utime.h sys/utime.h) # some standard structures AC_HEADER_STAT
Index: src/LyX.cpp =================================================================== --- src/LyX.cpp (revision 20108) +++ src/LyX.cpp (working copy) @@ -446,9 +446,6 @@ int LyX::exec(int & argc, char * argv[]) return !final_success; } - // Force adding of font path _before_ Application is initialized - support::os::addFontResources(); - // Let the frontend parse and remove all arguments that it knows pimpl_->application_.reset(createApplication(argc, argv)); @@ -483,9 +480,6 @@ int LyX::exec(int & argc, char * argv[]) prepareExit(); - // Restore original font resources after Application is destroyed. - support::os::restoreFontResources(); - return exit_status; } Index: src/frontends/qt4/GuiFontLoader.cpp =================================================================== --- src/frontends/qt4/GuiFontLoader.cpp (revision 20108) +++ src/frontends/qt4/GuiFontLoader.cpp (working copy) @@ -21,8 +21,11 @@ #include "support/filetools.h" #include "support/lstrings.h" #include "support/Systemcall.h" +#include "support/Package.h" +#include "support/os.h" #include <qfontinfo.h> +#include <QFontDatabase> #include <boost/tuple/tuple.hpp> @@ -33,6 +36,9 @@ #endif using lyx::support::contains; +using lyx::support::package; +using lyx::support::addPath; +using lyx::support::addName; using std::endl; using std::make_pair; @@ -41,6 +47,12 @@ using std::pair; using std::vector; using std::string; +#if QT_VERSION >= 0x040200 +string const math_fonts[] = {"cmex10", "cmmi10", "cmr10", "cmsy10", + "eufm10", "msam10", "msbm10", "wasy10", "esint10"}; +int const num_math_fonts = sizeof(math_fonts) / sizeof(*math_fonts); +#endif + namespace lyx { namespace frontend { @@ -189,6 +201,24 @@ pair<QFont, bool> const getSymbolFont(st GuiFontLoader::GuiFontLoader() { +#if QT_VERSION >= 0x040200 + fontID = new int[num_math_fonts]; + + string const fonts_dir = + addPath(package().system_support().absFilename(), "fonts"); + + for (int i = 0 ; i < num_math_fonts; ++i) { + string const font_file = lyx::support::os::external_path( + addName(fonts_dir, math_fonts[i] + ".ttf")); + fontID[i] = QFontDatabase::addApplicationFont(toqstr(font_file)); + + LYXERR(Debug::FONT) << "Adding font " << font_file + << static_cast<const char *> + (fontID[i] < 0 ? " FAIL" : " OK") + << endl; + } +#endif + for (int i1 = 0; i1 < Font::NUM_FAMILIES; ++i1) for (int i2 = 0; i2 < 2; ++i2) for (int i3 = 0; i3 < 4; ++i3) @@ -197,6 +227,19 @@ GuiFontLoader::GuiFontLoader() } +GuiFontLoader::~GuiFontLoader() +{ +#if QT_VERSION >= 0x040200 + for (int i = 0 ; i < num_math_fonts; ++i) { + if (fontID[i] >= 0) + QFontDatabase::removeApplicationFont(fontID[i]); + } + + delete [] fontID; +#endif +} + + void GuiFontLoader::update() { for (int i1 = 0; i1 < Font::NUM_FAMILIES; ++i1) Index: src/frontends/qt4/GuiFontLoader.h =================================================================== --- src/frontends/qt4/GuiFontLoader.h (revision 20108) +++ src/frontends/qt4/GuiFontLoader.h (working copy) @@ -47,7 +47,7 @@ public: GuiFontLoader(); /// Destructor - virtual ~GuiFontLoader() {} + ~GuiFontLoader(); virtual void update(); virtual bool available(Font const & f); @@ -73,6 +73,9 @@ public: } private: +#if QT_VERSION >= 0x040200 + int * fontID; +#endif /// BUTT ugly ! QLFontInfo * fontinfo_[Font::NUM_FAMILIES][2][4][10]; }; Index: src/support/os_cygwin.cpp =================================================================== --- src/support/os_cygwin.cpp (revision 20108) +++ src/support/os_cygwin.cpp (working copy) @@ -32,24 +32,6 @@ using std::string; using lyx::support::contains; -#ifdef X_DISPLAY_MISSING -#include "support/filetools.h" -#include "support/Package.h" -#include "support/Path.h" -using lyx::support::addName; -using lyx::support::addPath; -using lyx::support::package; - -// API definition for manually calling font functions on Windows 2000 and later -typedef int (WINAPI *FONTAPI)(LPCSTR, DWORD, PVOID); -#define FR_PRIVATE 0x10 - -// Names of TrueType fonts to load -string const win_fonts_truetype[] = {"cmex10", "cmmi10", "cmr10", "cmsy10", - "eufm10", "msam10", "msbm10", "wasy10", "esint10"}; -const int num_fonts_truetype = sizeof(win_fonts_truetype) / sizeof(*win_fonts_truetype); -#endif - namespace lyx { namespace support { @@ -294,59 +276,6 @@ bool autoOpenFile(string const & filenam win_path.c_str(), NULL, NULL, 1)) > 32; } - -void addFontResources() -{ -#ifdef X_DISPLAY_MISSING - // Windows only: Add BaKoMa TrueType font resources - string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); - - HMODULE hDLL = LoadLibrary("gdi32"); - FONTAPI pAddFontResourceEx = - (FONTAPI) GetProcAddress(hDLL, "AddFontResourceExA"); - - for (int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = to_local8bit(from_utf8(convert_path( - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"), - PathStyle(windows)))); - if (pAddFontResourceEx) { - // Windows 2000 and later: Use AddFontResourceEx - pAddFontResourceEx(font_current.c_str(), FR_PRIVATE, 0); - } else { - // Older Windows versions: Use AddFontResource - AddFontResource(font_current.c_str()); - } - } - FreeLibrary(hDLL); -#endif -} - - -void restoreFontResources() -{ -#ifdef X_DISPLAY_MISSING - // Windows only: Remove BaKoMa TrueType font resources - string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); - - HMODULE hDLL = LoadLibrary("gdi32"); - FONTAPI pRemoveFontResourceEx = (FONTAPI) GetProcAddress(hDLL, "RemoveFontResourceExA"); - - for(int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = to_local8bit(from_utf8(convert_path( - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"), - PathStyle(windows)))); - if (pRemoveFontResourceEx) { - // Windows 2000 and later: Use RemoveFontResourceEx - pRemoveFontResourceEx(font_current.c_str(), FR_PRIVATE, 0); - } else { - // Older Windows versions: Use RemoveFontResource - RemoveFontResource(font_current.c_str()); - } - } - FreeLibrary(hDLL); -#endif -} - } // namespace os } // namespace support } // namespace lyx Index: src/support/os_unix.cpp =================================================================== --- src/support/os_unix.cpp (revision 20108) +++ src/support/os_unix.cpp (working copy) @@ -13,19 +13,11 @@ #include <config.h> #include "support/os.h" -#include "debug.h" #ifdef __APPLE__ #include <Carbon/Carbon.h> -#include <ApplicationServices/ApplicationServices.h> -#elif defined(HAVE_FONTCONFIG_FONTCONFIG_H) -#include "support/filetools.h" -#include "support/Package.h" -#include <fontconfig/fontconfig.h> -using lyx::support::addPath; #endif -using std::endl; using std::string; @@ -200,52 +192,6 @@ bool autoOpenFile(string const & filenam #endif } - -void addFontResources() -{ -#ifdef __APPLE__ - CFBundleRef myAppBundle = CFBundleGetMainBundle(); - CFURLRef myAppResourcesURL, FontsURL; - FSRef fontDirRef; - FSSpec fontDirSpec; - CFStringRef filePath = CFStringCreateWithBytes(kCFAllocatorDefault, - (UInt8 *) "fonts", strlen("fonts"), - kCFStringEncodingISOLatin1, false); - - myAppResourcesURL = CFBundleCopyResourcesDirectoryURL(myAppBundle); - FontsURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault, - myAppResourcesURL, filePath, true); - if (lyxerr.debugging(Debug::FONT)) { - UInt8 buf[255]; - if (CFURLGetFileSystemRepresentation(FontsURL, true, buf, 255)) - lyxerr << "Adding Fonts directory: " << buf << endl; - } - CFURLGetFSRef (FontsURL, &fontDirRef); - OSStatus err = FSGetCatalogInfo (&fontDirRef, kFSCatInfoNone, - NULL, NULL, &fontDirSpec, NULL); - if (err) - lyxerr << "FSGetCatalogInfo err = " << err << endl; - err = FMActivateFonts (&fontDirSpec, NULL, NULL, - kFMLocalActivationContext); - if (err) - lyxerr << "FMActivateFonts err = " << err << endl; -#elif defined(HAVE_FONTCONFIG_FONTCONFIG_H) - // Register BaKoMa truetype fonts with fontconfig - string const fonts_dir = - addPath(package().system_support().absFilename(), "fonts"); - if (!FcConfigAppFontAddDir(0, (FcChar8 const *)fonts_dir.c_str())) - lyxerr << "Unable to register fonts with fontconfig." << endl; -#endif -} - - -void restoreFontResources() -{ -#if defined(HAVE_FONTCONFIG_FONTCONFIG_H) && !defined(__APPLE__) - FcConfigAppFontClear(0); -#endif -} - } // namespace os } // namespace support } // namespace lyx Index: src/support/os.h =================================================================== --- src/support/os.h (revision 20108) +++ src/support/os.h (working copy) @@ -109,19 +109,6 @@ bool canAutoOpenFile(std::string const & */ bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW); -/** General font utilities. - * FIXME: only MAC and WIN32 for now but it would be nice to convince - * fontconfig to do the same for linux. - */ - -/// Add fonts to the font subsystem, must be called before Application -/// is initialized. -void addFontResources(); - -/// Restore original font resources, must be called after Application -/// is destroyed. -void restoreFontResources(); - } // namespace os } // namespace support } // namespace lyx Index: src/support/os_win32.cpp =================================================================== --- src/support/os_win32.cpp (revision 20108) +++ src/support/os_win32.cpp (working copy) @@ -19,8 +19,6 @@ #include "support/lstrings.h" #include "support/filetools.h" #include "support/ExceptionMessage.h" -#include "support/Package.h" -#include "support/Path.h" #include "debug.h" #include "gettext.h" @@ -70,18 +68,6 @@ using std::string; using lyx::support::runCommand; using lyx::support::split; -using lyx::support::addName; -using lyx::support::addPath; -using lyx::support::package; - -// API definition for manually calling font functions on Windows 2000 and later -typedef int (WINAPI *FONTAPI)(LPCSTR, DWORD, PVOID); -#define FR_PRIVATE 0x10 - -// Names of TrueType fonts to load -string const win_fonts_truetype[] = {"cmex10", "cmmi10", "cmr10", "cmsy10", - "eufm10", "msam10", "msbm10", "wasy10", "esint10"}; -const int num_fonts_truetype = sizeof(win_fonts_truetype) / sizeof(*win_fonts_truetype); namespace lyx { @@ -407,54 +393,6 @@ bool autoOpenFile(string const & filenam to_local8bit(from_utf8(filename)).c_str(), NULL, NULL, 1)) > 32; } - -void addFontResources() -{ - // Windows only: Add BaKoMa TrueType font resources - string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); - - HMODULE hDLL = LoadLibrary("gdi32"); - FONTAPI pAddFontResourceEx = (FONTAPI) GetProcAddress(hDLL, "AddFontResourceExA"); - - for (int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"); - if (pAddFontResourceEx) { - // Windows 2000 and later: Use AddFontResourceEx for private font - pAddFontResourceEx(to_local8bit(from_utf8(external_path(font_current))).c_str(), FR_PRIVATE, 0); - } else { - // Older Windows versions: Use AddFontResource - AddFontResource(to_local8bit(from_utf8(external_path(font_current))).c_str()); - } - } - - FreeLibrary(hDLL); -} - - -void restoreFontResources() -{ - // Windows only: Remove BaKoMa TrueType font resources - string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); - - HMODULE hDLL = LoadLibrary("gdi32"); - FONTAPI pRemoveFontResourceEx = (FONTAPI) GetProcAddress(hDLL, "RemoveFontResourceExA"); - - for(int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"); - if (pRemoveFontResourceEx) { - // Windows 2000 and later: Use RemoveFontResourceEx for private font - pRemoveFontResourceEx(to_local8bit(from_utf8(external_path(font_current))).c_str(), FR_PRIVATE, 0); - } else { - // Older Windows versions: Use RemoveFontResource - RemoveFontResource(to_local8bit(from_utf8(external_path(font_current))).c_str()); - } - } - - FreeLibrary(hDLL); -} - } // namespace os } // namespace support } // namespace lyx Index: configure.ac =================================================================== --- configure.ac (revision 20108) +++ configure.ac (working copy) @@ -234,7 +234,7 @@ AC_LANG_POP(C) # some standard header files AC_HEADER_DIRENT AC_HEADER_MAJOR -AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h utime.h sys/utime.h io.h process.h NewAPIs.h fontconfig/fontconfig.h) +AC_CHECK_HEADERS(sys/time.h sys/types.h sys/select.h strings.h locale.h utime.h sys/utime.h io.h process.h NewAPIs.h) # some standard structures AC_HEADER_STAT