[mapguide-commits] r8372 - in trunk/MgDev: Common/MapGuideCommon/System Common/Renderers Server/src/Core

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Oct 1 08:13:01 PDT 2014


Author: jng
Date: 2014-10-01 08:13:01 -0700 (Wed, 01 Oct 2014)
New Revision: 8372

Modified:
   trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp
   trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h
   trunk/MgDev/Common/Renderers/FontManager.cpp
   trunk/MgDev/Common/Renderers/FontManager.h
   trunk/MgDev/Server/src/Core/Server.cpp
   trunk/MgDev/Server/src/Core/Server.h
Log:
#532: Add support for loading fonts from user-defined directories on Linux. Reviewed by Walt Welton-Lair

Modified: trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp	2014-09-30 12:29:52 UTC (rev 8371)
+++ trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.cpp	2014-10-01 15:13:01 UTC (rev 8372)
@@ -140,6 +140,8 @@
 const STRING MgConfigProperties::DefaultGeneralPropertyLicenseServerPath                    = L"";
 const STRING MgConfigProperties::GeneralPropertyLinuxMemDebug                               = L"LinuxMemDebug";
 const bool   MgConfigProperties::DefaultGeneralPropertyLinuxMemDebug                        = false;
+const STRING MgConfigProperties::GeneralPropertyLinuxFontDirectories                        = L"LinuxFontDirectories";
+const STRING MgConfigProperties::DefaultGeneralPropertyLinuxFontDirectories                 = L"";
 const STRING MgConfigProperties::GeneralPropertyLogsDelimiter                               = L"LogsDelimiter";
 const STRING MgConfigProperties::DefaultGeneralPropertyLogsDelimiter                        = L"\t";
 const STRING MgConfigProperties::GeneralPropertyLogsDetail                                  = L"LogsDetail";

Modified: trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h	2014-09-30 12:29:52 UTC (rev 8371)
+++ trunk/MgDev/Common/MapGuideCommon/System/ConfigProperties.h	2014-10-01 15:13:01 UTC (rev 8372)
@@ -86,6 +86,10 @@
     static const STRING GeneralPropertyLinuxMemDebug;               /// value("LinuxMemDebug")
     static const bool DefaultGeneralPropertyLinuxMemDebug;        /// value(false);
 
+    /// Optional Linux search paths for additional fonts
+    static const STRING GeneralPropertyLinuxFontDirectories;            /// value("LinuxFontDirectories")
+    static const STRING DefaultGeneralPropertyLinuxFontDirectories;     /// value("")
+
     /// Sets the field delimiter in the logs
     static const STRING GeneralPropertyLogsDelimiter;                   /// value("LogsDelimiter")
     static const STRING DefaultGeneralPropertyLogsDelimiter;            /// value("\t")

Modified: trunk/MgDev/Common/Renderers/FontManager.cpp
===================================================================
--- trunk/MgDev/Common/Renderers/FontManager.cpp	2014-09-30 12:29:52 UTC (rev 8371)
+++ trunk/MgDev/Common/Renderers/FontManager.cpp	2014-10-01 15:13:01 UTC (rev 8372)
@@ -239,15 +239,15 @@
     }
 }
 #else
-// initialize the font list
-void FontManager::init_font_list()
+int FontManager::AddLinuxFontDirectory(const char* fontDir)
 {
     AutoMutexLocker autoLocker(sm_mutex);
-
     int error = 0;
+    int added = 0;
 
-    string dirname(".");
-    DIR* pCurrent = opendir(dirname.c_str());
+    std::string sFontDir;
+    sFontDir.append(fontDir);
+    DIR* pCurrent = opendir(fontDir);
 
     while (pCurrent)
     {
@@ -256,7 +256,7 @@
 
         if (pDirent)
         {
-            string entryName = dirname;
+            string entryName = sFontDir;
             entryName += "/";
             entryName += pDirent->d_name;
 
@@ -282,6 +282,7 @@
                     wstring en;
                     UnicodeString::MultiByteToWideChar(entryName.c_str(), en);
                     create_font(face, index, en.c_str());
+                    added++;
 
                     // dispose of face
                     FT_Done_Face(face);
@@ -299,7 +300,16 @@
             pCurrent = NULL;    //  break out of while loop
         }
     }
+    return added;
 }
+// initialize the font list
+void FontManager::init_font_list()
+{
+    int added = AddLinuxFontDirectory(".");
+#ifdef _DEBUG
+    printf("Added %d fonts from default location\n", added);
+#endif
+}
 #endif  //  _WIN32
 
 

Modified: trunk/MgDev/Common/Renderers/FontManager.h
===================================================================
--- trunk/MgDev/Common/Renderers/FontManager.h	2014-09-30 12:29:52 UTC (rev 8371)
+++ trunk/MgDev/Common/Renderers/FontManager.h	2014-10-01 15:13:01 UTC (rev 8372)
@@ -65,6 +65,9 @@
         void init_font_list();
         void create_font(FT_Face face, FT_Long index, wchar_t const* filename);
 
+#ifndef _WIN32
+        RENDERERS_API int AddLinuxFontDirectory(const char* fontDir);
+#endif
         RENDERERS_API void AddFontAlias(const wchar_t* alias, const wchar_t* asciiName);
 
         FontList* GetFontList();

Modified: trunk/MgDev/Server/src/Core/Server.cpp
===================================================================
--- trunk/MgDev/Server/src/Core/Server.cpp	2014-09-30 12:29:52 UTC (rev 8371)
+++ trunk/MgDev/Server/src/Core/Server.cpp	2014-10-01 15:13:01 UTC (rev 8372)
@@ -695,6 +695,36 @@
     return nResult;
 }
 
+void MgServer::AddFontDirectories()
+{
+    //This is Linux-only
+#ifndef _WIN32
+    FontManager* fontManager = FontManager::Instance();
+    MgConfiguration* pConfiguration = MgConfiguration::GetInstance();
+    // Precache the specified maps
+    STRING fontDirs;
+    pConfiguration->GetStringValue(MgConfigProperties::GeneralPropertiesSection, MgConfigProperties::GeneralPropertyLinuxFontDirectories, fontDirs, MgConfigProperties::DefaultGeneralPropertyLinuxFontDirectories);
+
+    // Check if there is actually directories to add
+    if (!fontDirs.empty())
+    {
+        Ptr<MgStringCollection> fontDirCollection;
+        fontDirCollection = MgStringCollection::ParseCollection(fontDirs, L":");
+
+        if (fontDirCollection->GetCount() > 0)
+        {
+            for (INT32 i = 0; i < fontDirCollection->GetCount(); i++)
+            {
+                STRING fontDir = fontDirCollection->GetItem(i);
+                std::string mbFontDir = MgUtil::WideCharToMultiByte(fontDir);
+                int added = fontManager->AddLinuxFontDirectory(mbFontDir.c_str());
+                ACE_DEBUG((LM_INFO, ACE_TEXT("(%t) Added %d fonts from directory: %W\n"), added, fontDir.c_str()));
+            }
+        }
+    }
+#endif
+}
+
 void MgServer::AddFontManagerFontAliases()
 {
     FontManager* fontManager = FontManager::Instance();
@@ -973,6 +1003,10 @@
             pConfiguration->GetStringValue(MgConfigProperties::FeatureServicePropertiesSection, MgConfigProperties::FeatureServicePropertyDataConnectionPoolSizeCustom, dataConnectionPoolSizeCustom, MgConfigProperties::DefaultFeatureServicePropertyDataConnectionPoolSizeCustom);
             pConfiguration->GetStringValue(MgConfigProperties::FeatureServicePropertiesSection, MgConfigProperties::FeatureServicePropertyDataConnectionUseLimit, dataConnectionUseLimit, MgConfigProperties::DefaultFeatureServicePropertyDataConnectionUseLimit);
 
+            // Add additional font directories to the FontManager
+            ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t) MgServer::open() - Adding extra font directories.\n")));
+            AddFontDirectories();
+
             // Add additional font mappings to the FontManager
             ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t) MgServer::open() - Adding Font Manager Mappings.\n")));
             AddFontManagerFontAliases();

Modified: trunk/MgDev/Server/src/Core/Server.h
===================================================================
--- trunk/MgDev/Server/src/Core/Server.h	2014-09-30 12:29:52 UTC (rev 8371)
+++ trunk/MgDev/Server/src/Core/Server.h	2014-10-01 15:13:01 UTC (rev 8372)
@@ -115,6 +115,7 @@
 
     void ParseArgs(INT32 argc, ACE_TCHAR *argv[]);
     void AddFontManagerFontAliases();
+    void AddFontDirectories();
     static STRING LocaleCallback();
 
     ///////////////////////////////////////////////////////



More information about the mapguide-commits mailing list