]> git.lyx.org Git - features.git/commitdiff
allow mac os x to find its fonts
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 15 Jan 2004 16:07:17 +0000 (16:07 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 15 Jan 2004 16:07:17 +0000 (16:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8356 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/QLMenubar.C
src/frontends/qt2/qfont_loader.C

index 86a96b38228014a308b2983a44bb80106033da9b..f68f54810a48f5d4117f2fff03972a52b6622f0f 100644 (file)
@@ -1,3 +1,11 @@
+2004-01-15  Ronald Florence  <ron@18james.com>
+
+       * Menubar_pimpl.C: change Q_WS_MAC conditional define to
+       Q_WS_MACX.
+
+       * qfont_loader.C: add support for LyX/Mac to find Fonts directory
+       inside the application bundle.
+
 2004-01-08  Angus Leeming  <leeming@lyx.org>
 
        * FileDialog.C (open, save):
index ec63f09ca2f7b6ea06be124b3d96b5f7e1e2bce0..9fafbc54033823a5fae6b45cfd15d65735fd2363 100644 (file)
@@ -33,7 +33,7 @@ QLMenubar::QLMenubar(LyXView * view, MenuBackend const & mbe)
                pair<int, QLPopupMenu *> menu =
                        createMenu(owner_->menuBar(), &(*m), this, true);
                name_map_[m->submenuname()] = menu.second;
-#ifdef Q_WS_MAC
+#ifdef Q_WS_MACX
                /* The qt/mac menu code has a very silly hack that
                   moves some menu entries that it recognizes by name
                   (ex: "Preferences...") to the "LyX" menu. This
index 8fb2f8bc75392ce618b11e7fd63fe56d2a333df5..7d545405e1804fdc9a77bcb7d37f5078aaabfa79 100644 (file)
@@ -43,6 +43,10 @@ using std::pair;
 using std::vector;
 using std::string;
 
+#ifdef Q_WS_MACX
+#include <ApplicationServices/ApplicationServices.h>
+#endif
+
 namespace {
 
 void addFontPath()
@@ -65,6 +69,33 @@ void addFontPath()
                       << endl;
        }
 #endif
+#ifdef Q_WS_MACX
+       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
 }
 
 
@@ -351,6 +382,13 @@ bool qfont_loader::available(LyXFont const & f)
 {
        if (!lyx_gui::use_gui)
                return false;
+#ifdef Q_WS_MACX
+       static bool need_bundle_fonts = true;
+       if (need_bundle_fonts) {
+               addFontPath();
+               need_bundle_fonts = false;
+       }
+#endif
 
        static vector<bool> cache_set(LyXFont::NUM_FAMILIES, false);
        static vector<bool> cache(LyXFont::NUM_FAMILIES, false);