Enrico Forestieri wrote: > On Tue, Jul 03, 2007 at 08:13:42PM +0200, Peter Kümmel wrote: > >> Peter Kümmel wrote: >>> Jürgen Spitzmüller wrote: >>>> Abdelrazak Younes wrote: >>>>>> 3962 cri (Math) Font problems on Windows >>>>> This one is a packaging issue right? >>>> No, AFAIU you need to replace AddFontRessource and RemoveFontRessourse in >>>> support/os_win32.spp with AddFontResourceEx and RemoveFontResourceEx. >>> >>> Does attached patch solve the problem? >>> >>> Both functions are not supported by older Window versions. >>> Therefore we have to decides at runtime which function to call. >>> >> Compiles also with Qt 4.1: >> http://doc.trolltech.com/4.1/qsysinfo.html > > Please, could you also take care of that in os_cygwin.cpp, or do > you prefer that I do it? >
Ok, here with the changes for cygwin, BUT I couldn't test it. -- Peter Kümmel
Index: src/support/os_cygwin.cpp =================================================================== --- src/support/os_cygwin.cpp (revision 18974) +++ src/support/os_cygwin.cpp (working copy) @@ -19,7 +19,13 @@ #include "debug.h" + +// compile with Windows > Win98 API, but guard >Win98 API calls +// only needed for AddFontResourceEx +#define _WIN32_WINNT 0x0500 +#define WIN32_LEAN_AND_MEAN #include <windows.h> + #include <io.h> #include <windef.h> #include <shellapi.h> @@ -27,6 +33,9 @@ #include <sys/cygwin.h> +#include <QSysInfo> + + using std::endl; using std::string; @@ -331,10 +340,17 @@ string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); 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)))); - AddFontResource(font_current.c_str()); + if (QSysInfo::WindowsVersion < QSysInfo::WV_NT ) { + string const font_current = to_local8bit(from_utf8(convert_path( + addName(fonts_dir, win_fonts_truetype[i] + ".ttf"), + PathStyle(windows)))); + AddFontResource(font_current.c_str()); + } else { + string const font_current = to_local8bit(from_utf8(convert_path( + addName(fonts_dir, win_fonts_truetype[i] + "_LyX.ttf"), + PathStyle(windows)))); + AddFontResourceEx(font_current.c_str(), FR_PRIVATE, 0); + } } #endif } @@ -347,10 +363,17 @@ string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); 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)))); - RemoveFontResource(font_current.c_str()); + if (QSysInfo::WindowsVersion < QSysInfo::WV_NT ) { + string const font_current = to_local8bit(from_utf8(convert_path( + addName(fonts_dir, win_fonts_truetype[i] + ".ttf"), + PathStyle(windows)))); + RemoveFontResource(font_current.c_str()); + } else { + string const font_current = to_local8bit(from_utf8(convert_path( + addName(fonts_dir, win_fonts_truetype[i] + "_LyX.ttf"), + PathStyle(windows)))); + RemoveFontResourceEx(font_current.c_str(), FR_PRIVATE, 0); + } } #endif } Index: src/support/os_win32.h =================================================================== --- src/support/os_win32.h (revision 18974) +++ src/support/os_win32.h (working copy) @@ -42,6 +42,10 @@ # define _WIN32_IE 0x0500 #endif +// compile with Windows > Win98 API, but guard >Win98 API calls +// only needed for AddFontResourceEx +#define _WIN32_WINNT 0x0500 +#define WIN32_LEAN_AND_MEAN #include <windows.h> Index: src/support/os_win32.cpp =================================================================== --- src/support/os_win32.cpp (revision 18974) +++ src/support/os_win32.cpp (working copy) @@ -30,6 +30,8 @@ #include <cstdlib> #include <vector> +#include <QSysInfo> + /* The GetLongPathName macro may be defined on the compiling machine, * but we must use a bit of trickery if the resulting executable is * to run on a Win95 machine. @@ -409,9 +411,14 @@ string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); for (int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"); - AddFontResource(to_local8bit(from_utf8(external_path(font_current))).c_str()); + if (QSysInfo::WindowsVersion < QSysInfo::WV_NT ) { + string const font_current = addName(fonts_dir, win_fonts_truetype[i] + ".ttf"); + AddFontResource(to_local8bit(from_utf8(external_path(font_current))).c_str()); + } else { + string const font_current = addName(fonts_dir, win_fonts_truetype[i] + "_LyX.ttf"); + AddFontResourceEx(to_local8bit(from_utf8(external_path(font_current))).c_str(), + FR_PRIVATE, 0); + } } } @@ -422,9 +429,14 @@ string const fonts_dir = addPath(package().system_support().absFilename(), "fonts"); for(int i = 0 ; i < num_fonts_truetype ; ++i) { - string const font_current = - addName(fonts_dir, win_fonts_truetype[i] + ".ttf"); - RemoveFontResource(to_local8bit(from_utf8(external_path(font_current))).c_str()); + if (QSysInfo::WindowsVersion < QSysInfo::WV_NT ) { + string const font_current = addName(fonts_dir, win_fonts_truetype[i] + ".ttf"); + RemoveFontResource(to_local8bit(from_utf8(external_path(font_current))).c_str()); + } else { + string const font_current = addName(fonts_dir, win_fonts_truetype[i] + "_LyX.ttf"); + RemoveFontResourceEx(to_local8bit(from_utf8(external_path(font_current))).c_str(), + FR_PRIVATE, 0); + } } }