]> git.lyx.org Git - features.git/commitdiff
Log:
authorEnrico Forestieri <forenr@lyx.org>
Thu, 11 Jan 2007 21:22:18 +0000 (21:22 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 11 Jan 2007 21:22:18 +0000 (21:22 +0000)
Move OS dependent code where it belongs.

* src/lyx_cb.C:
Remove unused include

* src/support/os.h
* src/support/os_unix.C
* src/support/os_win32.C
* src/support/os_cygwin.C:
Move here the code from fontutils.[Ch]

* src/support/os_cygwin.C
(external_path, external_path_list): don't differentiate anymore
on Qt/X11 or Qt/Win builds.

* src/support/environment.C
(setEnvPath): get rid of the #ifdef for cygwin.

* src/lyx_main.C
(LyX::exec): addFontResources and restoreFontResources are now
in the os namespace.

* src/support/Makefile.am
* src/client/Makefile.am
* src/tex2lyx/Makefile.am
* development/scons/scons_manifest.py:
Updated

* src/support/fontutils.[Ch]:
Removed

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

13 files changed:
development/scons/scons_manifest.py
src/client/Makefile.am
src/lyx_cb.C
src/lyx_main.C
src/support/Makefile.am
src/support/environment.C
src/support/fontutils.C [deleted file]
src/support/fontutils.h [deleted file]
src/support/os.h
src/support/os_cygwin.C
src/support/os_unix.C
src/support/os_win32.C
src/tex2lyx/Makefile.am

index d51e08c3903b48228de1a39f41d9bf8b0004d790..7bc6f83e83d8b6d4588de880c4dab96c8223987c 100644 (file)
@@ -102,7 +102,6 @@ src_support_header_files = Split('''
     filefilterlist.h
     filename.h
     filetools.h
-    fontutils.h
     forkedcall.h
     forkedcallqueue.h
     forkedcontr.h
@@ -142,7 +141,6 @@ src_support_files = Split('''
     filefilterlist.C
     filename.C
     filetools.C
-    fontutils.C
     forkedcall.C
     forkedcallqueue.C
     forkedcontr.C
index 6331ddfb4b773486eb7dd4418c46ff5391341554..e3f2d95aa1240345f93aa923af5322059ef0d000 100644 (file)
@@ -16,7 +16,7 @@ BOOST_LIBS = $(BOOST_REGEX) $(BOOST_FILESYSTEM)
 
 lyxclient_LDADD = \
        $(top_builddir)/src/support/libsupport.la \
-       $(BOOST_LIBS) $(LIBICONV) $(INTLLIBS) $(SOCKET_LIBS)
+       $(BOOST_LIBS) $(LIBICONV) $(INTLLIBS) @LIBS@ $(SOCKET_LIBS)
 
 lyxclient_SOURCES = \
        boost.C \
index 14cca99832573202556feb5aec5a02fb89949df6..a60882ba5e80d0919609c110fc86ef3126e129f2 100644 (file)
@@ -38,7 +38,6 @@
 
 #include "support/filefilterlist.h"
 #include "support/filetools.h"
-#include "support/fontutils.h"
 #include "support/forkedcall.h"
 #include "support/fs_extras.h"
 #include "support/lyxlib.h"
index add424f8b0f2f7f353b269b0a99fb78dcd4553ba..56605bf9b042b6c9ebdbdec60f84a886f74764f9 100644 (file)
@@ -50,7 +50,6 @@
 
 #include "support/environment.h"
 #include "support/filetools.h"
-#include "support/fontutils.h"
 #include "support/lyxlib.h"
 #include "support/convert.h"
 #include "support/os.h"
@@ -366,7 +365,7 @@ int LyX::exec(int & argc, char * argv[])
        }
 
        // Force adding of font path _before_ Application is initialized
-       support::addFontResources();
+       support::os::addFontResources();
 
        // Let the frontend parse and remove all arguments that it knows
        pimpl_->application_.reset(createApplication(argc, argv));
@@ -403,7 +402,7 @@ int LyX::exec(int & argc, char * argv[])
        prepareExit();
 
        // Restore original font resources after Application is destroyed.
-       support::restoreFontResources();
+       support::os::restoreFontResources();
 
        return exit_status;
 }
index 9bb4815e72eb1d01b8b62ac617a3b1a6e97c8942..3ad9d9fc5fcf76cc2ffb716a38e2406cae9beba2 100644 (file)
@@ -41,8 +41,6 @@ libsupport_la_SOURCES = \
        filename.h \
        filetools.C \
        filetools.h \
-       fontutils.C \
-       fontutils.h \
        forkedcall.C \
        forkedcall.h \
        forkedcallqueue.C \
index 616025cf2a47ee78e0c790cab5805937a77bf673..c1a5710978608c5e304ccde41ed541fcd7a907bd 100644 (file)
@@ -95,14 +95,7 @@ void setEnvPath(string const & name, vector<string> const & env)
        for (; it != end; ++it) {
                if (it != begin)
                        ss << separator;
-#if defined(__CYGWIN__) || defined(__CYGWIN32__)
-               // On cygwin, os::external_path returns either posix or
-               // pseudo-win style paths, but here we always need posix style.
-               // This fixes bug 2344.
-               ss << os::internal_path(*it);
-#else
                ss << os::external_path(*it);
-#endif
        }
        setEnv(name, ss.str());
 }
diff --git a/src/support/fontutils.C b/src/support/fontutils.C
deleted file mode 100644 (file)
index 96c92fd..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * \file fontutils.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Asger Alstrup
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- *
- * General font utilities.
- */
-
-#include <config.h>
-
-#include "fontutils.h"
-
-#include "support/filetools.h"
-#include "support/lstrings.h"
-#include "support/systemcall.h"
-
-#ifdef __APPLE__
-#include "debug.h"
-#include <ApplicationServices/ApplicationServices.h>
-using std::endl;
-#endif
-
-#if defined(_WIN32) || (defined(__CYGWIN__) && defined(X_DISPLAY_MISSING))
-#include "windows.h"
-#ifdef max
-#undef max
-#endif
-#ifdef min
-#undef min
-#endif
-#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;
-
-using std::string;
-
-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 {
-
-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;
-#endif
-
-#if defined(_WIN32) || (defined(__CYGWIN__) && defined(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 = 
-                       addName(fonts_dir, win_fonts_truetype[i] + ".ttf");
-               AddFontResource(os::external_path(font_current).c_str());
-       }
-#endif
-}
-
-
-void restoreFontResources()
-{
-#if defined(_WIN32) || (defined(__CYGWIN__) && defined(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 = 
-                       addName(fonts_dir, win_fonts_truetype[i] + ".ttf");
-               RemoveFontResource(os::external_path(font_current).c_str());
-       }
-#endif
-}
-
-} //namespace support
-} // namespace lyx
diff --git a/src/support/fontutils.h b/src/support/fontutils.h
deleted file mode 100644 (file)
index 1e5a468..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// -*- C++ -*-
-/**
- * \file fontutils.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- *
- * General font utilities.
- * FIXME: only MAC and WIN32 for now but it would be nice to convince
- * fontconfig to do the same for linux.
- */
-
-#ifndef LYX_FONTUTILS_H
-#define LYX_FONTUTILS_H
-
-namespace lyx {
-namespace support {
-
-/// 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 support
-} // namespace lyx
-
-#endif
index 90cf569da2b1832709449d37204bb99021833587..d4b103f1064f6f851d06ebb6685962ee72a87f97 100644 (file)
@@ -102,6 +102,19 @@ bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
  */
 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 fafbaccf5cbe86fd1e5b56f4a41d884190c8b59a..d281294ab7bbc3a1a4ee2b4312df7f0a6017524c 100644 (file)
@@ -32,6 +32,19 @@ 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;
+
+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 {
@@ -188,11 +201,7 @@ string::size_type common_path(string const & p1, string const & p2)
 
 string external_path(string const & p)
 {
-#ifdef X_DISPLAY_MISSING
-       return convert_path(p, PathStyle(windows));
-#else
        return convert_path(p, PathStyle(posix));
-#endif
 }
 
 
@@ -204,11 +213,7 @@ string internal_path(string const & p)
 
 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
 }
 
 
@@ -310,6 +315,37 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
 }
 
 
+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 = 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 = convert_path(
+                       addName(fonts_dir, win_fonts_truetype[i] + ".ttf"),
+                       PathStyle(windows));
+               RemoveFontResource(font_current.c_str());
+       }
+#endif
+}
+
 } // namespace os
 } // namespace support
 } // namespace lyx
index 03efbdd3b037ed239d1defaecb415e56e2a5f834..aff294b7b4b6ade31fb64ed57972215047877008 100644 (file)
 #include "support/os.h"
 
 #ifdef __APPLE__
+#include "debug.h"
 #include <Carbon/Carbon.h>
+#include <ApplicationServices/ApplicationServices.h>
+using std::endl;
 #endif
 
 using std::string;
@@ -192,6 +195,42 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
 #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;
+#endif
+}
+
+
+void restoreFontResources()
+{}
+
 } // namespace os
 } // namespace support
 } // namespace lyx
index c6624eadc4cd17c611a1acc45705d41f37ec8f46..468e8491c210479ab5ee5e24d61e4fe2996f06c4 100644 (file)
@@ -18,6 +18,8 @@
 #include "support/os_win32.h"
 #include "support/lstrings.h"
 #include "support/filetools.h"
+#include "support/package.h"
+#include "support/path.h"
 
 #include "debug.h"
 
@@ -68,6 +70,13 @@ using std::string;
 
 using lyx::support::runCommand;
 using lyx::support::split;
+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);
 
 
 namespace lyx {
@@ -406,6 +415,31 @@ bool autoOpenFile(string const & filename, auto_open_mode const mode)
 }
 
 
+void addFontResources()
+{
+       // 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(external_path(font_current).c_str());
+       }
+}
+
+
+void restoreFontResources()
+{
+       // 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(external_path(font_current).c_str());
+       }
+}
+
 } // namespace os
 } // namespace support
 } // namespace lyx
index 980f4ca1eee68e62b81b779424541a75a4d1a171..ddbc173689510ec3928456e5ff95e872f7e6a59b 100644 (file)
@@ -56,7 +56,7 @@ tex2lyx_SOURCES = \
 
 tex2lyx_LDADD = \
        $(top_builddir)/src/support/libsupport.la \
-       $(BOOST_LIBS) $(LIBICONV) $(COMPRESSIONLIB)
+       $(BOOST_LIBS) $(LIBICONV) @LIBS@ $(COMPRESSIONLIB)
 
 $(LINKED_FILES) :
        @rm -f $@ ; \