Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fonts are no longer working #1488

Closed
jirislaby opened this issue Jan 1, 2022 · 4 comments
Closed

Fonts are no longer working #1488

jirislaby opened this issue Jan 1, 2022 · 4 comments
Labels
bug An error which causes unexpected or unintended results fixed A bug that has been fixed os specific A bug which occurs only on particular operating systems regression A new bug which was not present in previous version

Comments

@jirislaby
Copy link

After commit e666fb1, fonts are not loaded as the paths in RS_System::getDirectoryList are incorrect. Like:

dirList ("/home/xslaby/.librecad/fonts", "/home/share/doc/librecad/fonts", "/home/share/librecad/fonts", "/home/lib/librecad/fonts")

Before that commit, the code did:

dirList.append( "/usr/share/" + appDirName + "/" + subDirectory);

which resulted in correct /usr/share/librecad/fonts.

@lordofbikes
Copy link
Member

lordofbikes commented Jan 4, 2022

The basic idea behind this change is, that an AppImage is mounted as loop device in /tmp in a randomly named folder. Inside this folder we have a root file system.
So the concept is to read the executable path on start up and find system folders relative to the executable.
This should then work for AppImage and distribution packages.

Usually packet maintainers will place librecad executable in /usr/bin. LibreCAD then search for resources in /usr/bin/../share/librecad/ which results in /usr/share/librecad/.
This is what you expected.
But from your list I assume that the librecad executable is in your home folder /home/xslaby/ which will result in /home/xslaby/../share/librecad/ which is /home/share/librecad/ effectively.

So the problem is presumably the correct placement after building from source. When you have fonts and other things in /usr/share/librecad, you should place librecad in /usr/bin, then it should work.

There is the script scripts/postprocess-unix.sh which collects everything needed in [LibreCAD_ROOT]/unix after build. This folder contains fonts, patterns, libraries and more.
Running librecad from this folder works for me well. This is also the described way in build instructions.

So the options I see (for self builder) are to run librecad in place with [LibreCAD-ROOT]/unix/librecad or move the whole unix folder to any other place and run it from there.

We can also add instructions, where to place the needed files and folders. But this may vary on different distributions and also need sudo permission, e.g. to copy/link files to /usr.

You can take a look at CI/build-appimg.sh to see where all the resources from unix folder are copied to. Remove appdir from destination paths and you see the /usr paths. These paths are usually used on Debian based distributions.

@lordofbikes lordofbikes added inquiry A question about a feature or possible bug regression A new bug which was not present in previous version labels Jan 4, 2022
@jirislaby
Copy link
Author

jirislaby commented Jan 5, 2022

@lordofbikes Sorry for not being specific, I am using lirbecad from openSUSE Tumbleweed. I.e. it is installed in /usr/bin.

Note that prgDir is the current directory, not /usr/bin. You'd have to start librecad as /usr/bin/librecad for prgDir to be /usr/bin, look at the code:

QFileInfo prgInfo( QFile::decodeName(argv[0]) );
QString prgDir(prgInfo.absolutePath());
RS_SETTINGS->init(app.organizationName(), app.applicationName());
RS_SYSTEM->init(app.applicationName(), app.applicationVersion(), XSTR(QC_APPDIR), prgDir);

So use QCoreApplication::applicationDirPath() there? Doing this code:

#include <QCoreApplication>
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QString>

int main(int argc, char **argv)
{
        QCoreApplication app(argc, argv);
        QFileInfo prgInfo( QFile::decodeName(argv[0]) );
        QString prgDir(prgInfo.absolutePath());

        qDebug() << "prgDir" << prgDir;
        qDebug() << "applicationDirPath" << QCoreApplication::applicationDirPath();

        return 0;
}

Compile it and run it elsewhere:

$ cd /tmp/q
$ g++ -Wall -g -DQT_CORE_LIB -I/usr/include/qt5/QtCore -I/usr/include/qt5     main.cpp  -lQt5Core  -o main
$ export PATH=$PATH:/tmp/q
$ cd
$ main
prgDir "/home/xslaby"
applicationDirPath "/tmp/q"

@lordofbikes
Copy link
Member

Finally I got it, the missing link was:

$ export PATH=$PATH:/tmp/q

argv[0] does not contain any path information when the executable is located through $PATH.
QFileInfo::absolutePath() then seems to fallback to pwd, which explains your observations.

I already used QCoreApplication::applicationDirPath() in e666fb1, so this should have worked. But I removed it in a64f1f4 because appDir and binDir was always the same for me.

There are a couple conditions in RS_System::getDirectoryList() I already wondered about, but now they makes sense. Some of them seem obsolete when using QCoreApplication::applicationDirPath(), I'll check this and it will need some detailed testing then.

@lordofbikes lordofbikes added bug An error which causes unexpected or unintended results os specific A bug which occurs only on particular operating systems fixed A bug that has been fixed and removed inquiry A question about a feature or possible bug labels Jan 6, 2022
lordofbikes added a commit that referenced this issue Jan 6, 2022
@pollywinters pollywinters mentioned this issue Apr 13, 2022
pollywinters pushed a commit to pollywinters/LibreCAD that referenced this issue Apr 14, 2022
@app4soft
Copy link
Contributor

app4soft commented Jun 7, 2023

@lordofbikes @dxli, Latest AppImage LibreCAD-2.2.1_alpha-125-ga28f13b5-x86_64.AppImage got this issue again.

ADDITION: Previous LibreCAD-2.2.1_alpha-85-g2d000d15-x86_64.AppImage has no such issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error which causes unexpected or unintended results fixed A bug that has been fixed os specific A bug which occurs only on particular operating systems regression A new bug which was not present in previous version
Projects
None yet
Development

No branches or pull requests

3 participants