#include <config.h>
#include "support/os.h"
-#include "support/lstrings.h"
-#include "debug.h"
+#include "support/FileName.h"
+#include "support/lstrings.h"
+#include "support/debug.h"
#include <windows.h>
#include <io.h>
#include <sys/cygwin.h>
-using std::endl;
-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
-
+using namespace std;
namespace lyx {
namespace support {
// on windows_style_tex_paths_), but we use always forward slashes,
// since it gets written into a .tex file.
- if (windows_style_tex_paths_ && is_absolute_path(p)) {
+ if (windows_style_tex_paths_ && FileName(p).isAbsolute()) {
string dos_path = convert_path(p, PathStyle(windows));
- LYXERR(Debug::LATEX)
- << "<Path correction for LaTeX> ["
- << p << "]->>["
- << dos_path << ']' << endl;
+ LYXERR(Debug::LATEX, "<Path correction for LaTeX> ["
+ << p << "]->>[" << dos_path << ']');
return dos_path;
}
}
-bool is_absolute_path(string const & p)
-{
- if (p.empty())
- return false;
-
- bool isDosPath = (p.length() > 1 && p[1] == ':');
- bool isUnixPath = (p[0] == '/');
-
- return isDosPath || isUnixPath;
-}
-
-
// returns a string suitable to be passed to popen when
// reading a pipe
char const * popen_read_mode()
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