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;
+
+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 {
};
+/// Convert a path to or from posix style.
+/// \p p is encoded in local 8bit encoding or utf8.
+/// The result is returned in the same encoding as \p p.
string convert_path(string const & p, PathStyle const & target)
{
char path_buf[PATH_MAX];
path_buf[0] = '\0';
+ // cygwin_conv_to_posix_path and cygwin_conv_to_win32_path do not
+ // care about the encoding.
if (target == posix)
cygwin_conv_to_posix_path(p.c_str(), path_buf);
else
}
+/// Convert a path list to or from posix style.
+/// \p p is encoded in local 8bit encoding or utf8.
+/// The result is returned in the same encoding as \p p.
string convert_path_list(string const & p, PathStyle const & target)
{
if (p.empty())
char * ptr = new char[target_size];
if (ptr) {
+ // FIXME: See comment in convert_path() above
if (target == posix)
cygwin_win32_to_posix_path_list(pc, ptr);
else
string external_path(string const & p)
{
-#ifdef X_DISPLAY_MISSING
- return convert_path(p, PathStyle(windows));
-#else
return convert_path(p, PathStyle(posix));
-#endif
}
string external_path_list(string const & p)
{
-#ifdef X_DISPLAY_MISSING
- return convert_path_list(p, PathStyle(windows));
-#else
return convert_path_list(p, PathStyle(posix));
-#endif
}
{
// reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc
// /platform/shell/reference/functions/shellexecute.asp
- string const win_path = convert_path(filename, PathStyle(windows));
+ string const win_path = to_local8bit(from_utf8(convert_path(filename, PathStyle(windows))));
char const * action = (mode == VIEW) ? "open" : "edit";
return reinterpret_cast<int>(ShellExecute(NULL, action,
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(), "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());
+ }
+#endif
+}
+
+
+void restoreFontResources()
+{
+#ifdef X_DISPLAY_MISSING
+ // 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 = to_local8bit(from_utf8(convert_path(
+ addName(fonts_dir, win_fonts_truetype[i] + ".ttf"),
+ PathStyle(windows))));
+ RemoveFontResource(font_current.c_str());
+ }
+#endif
+}
+
} // namespace os
} // namespace support
} // namespace lyx