Improvement to locating font directories

Posted by bgoodr on
URL: https://forum.librecad.org/Improvement-to-locating-font-directories-tp5706774.html

The default location of things like fonts needs to be relative to wherever the librecad executable is located. This is for local installs versus in /usr/bin.  This is in the use case of when you are building from source.

I have hacked my local sources to effect this by storing the fonts and other runtime directories in ../share relative to the bin directory, which is fairly standard fare.

Here is the patch:

diff --git a/librecad/src/lib/engine/rs_system.cpp b/librecad/src/lib/engine/rs_system.cpp
index 8fa40f8..15d5ce9 100644
--- a/librecad/src/lib/engine/rs_system.cpp
+++ b/librecad/src/lib/engine/rs_system.cpp
@@ -536,6 +536,10 @@ QStringList RS_System::getDirectoryList(const QString& _subDirectory) {
             }
         }
 
+        // share directory relative to the bin directory in the installation directory:
+        QFileInfo fileinfo(QCoreApplication::applicationDirPath());
+        QString finalDir(fileinfo.dir().path() + "/share/" + appDirName + "/" + subDirectory);
+        dirList.append(finalDir);
         // Ubuntu
         dirList.append("/usr/share/doc/" + appDirName + "/" + subDirectory);