From 842adc894d1ece8b6d092671d557421829a4b097 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 15 Jan 2004 16:07:17 +0000 Subject: [PATCH] allow mac os x to find its fonts git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8356 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 8 +++++++ src/frontends/qt2/QLMenubar.C | 2 +- src/frontends/qt2/qfont_loader.C | 38 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 86a96b3822..f68f54810a 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,11 @@ +2004-01-15 Ronald Florence + + * 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 * FileDialog.C (open, save): diff --git a/src/frontends/qt2/QLMenubar.C b/src/frontends/qt2/QLMenubar.C index ec63f09ca2..9fafbc5403 100644 --- a/src/frontends/qt2/QLMenubar.C +++ b/src/frontends/qt2/QLMenubar.C @@ -33,7 +33,7 @@ QLMenubar::QLMenubar(LyXView * view, MenuBackend const & mbe) pair 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 diff --git a/src/frontends/qt2/qfont_loader.C b/src/frontends/qt2/qfont_loader.C index 8fb2f8bc75..7d545405e1 100644 --- a/src/frontends/qt2/qfont_loader.C +++ b/src/frontends/qt2/qfont_loader.C @@ -43,6 +43,10 @@ using std::pair; using std::vector; using std::string; +#ifdef Q_WS_MACX +#include +#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 cache_set(LyXFont::NUM_FAMILIES, false); static vector cache(LyXFont::NUM_FAMILIES, false); -- 2.39.2