Solved [debug/qrc_fontawsome.cpp] Error 1
-
This is working fine for me:
main.cpp
#include <QtCore> int main(int argc, char **argv) { QCoreApplication app(argc, argv); if (QFile::exists(":/my.otf")) qDebug() << "File exists"; else qDebug() << "File does not exist"; return 0; }
tmp.qrc:
<RCC> <qresource prefix="/"> <file alias="my.otf">Font Awesome 5 Free-Regular-400.otf</file> </qresource> </RCC>
Compiled with
qmake -proejct qmake make
The file is from https://github.com/FortAwesome/Font-Awesome/blob/master/otfs/Font Awesome 5 Free-Regular-400.otf
-
@Christian-Ehrlicher I downloaded the file from the link you provided and put it into my project folder. Also I wrote your suggested code and got "File exists".
Now I got no errors, but I got the following result:The unicode I used is from here
I changed the code in the resource file as you posted:
<RCC> <qresource prefix="/"> <file alias="my.otf">Font Awesome 5 Free-Regular-400.otf</file> </qresource> </RCC>
Also, I updated my cpp file as your posted code:
#include "dialog.h" #include "ui_dialog.h" #include <QFontDatabase> #include <QFont> #include <QPushButton> Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this); QFontDatabase::addApplicationFont(":/my.otf"); QFont font; font.setFamily("FontAwesome"); font.setPixelSize(32); QPushButton *button = new QPushButton(this); button->setFont(font); button->setText("\uf083"); } Dialog::~Dialog() { delete ui; }
-
I don't know what symbol is behind "\uf083" nor do I know if the font contains this symbol.
-
@Christian-Ehrlicher The unicode " f083" is from here. This is the unicode for camera.
The code I posted above is from here.
I am supposed to have something like this:
-
I can't see what's going wrong here. My only idea would be that the symbol is not available but I can't test it.
If you think this is a Qt bug please open a bugreport at https://bugreports.qt.io/edit: I did some more testing and would guess the symbol is not in the otf file - see http://prntscr.com/vbba17 - only a few icons are shown.
-
Ok, it's in Font Awesome 5 Free-Solid-900.otf in the free part available from https://fontawesome.com/download
-
@Christian-Ehrlicher Thank you so much for helping. I downloaded Awesome 5 Free-Solid-900.otf from the link you provided, but stilI got the picture bellow:
I also downloaded the svg file from here, and I got the same output!
-
It is working fine for me when I add
Font Awesome 5 Free-Solid-900.otf
to the resource file and load the font from there.
Don't know what you want with the svg though. -
@Christian-Ehrlicher Could you please send me your code, if its possible? Thanks.
-
@nanor I already posted my code above, simply replace the filename for the otf file.
-
@Christian-Ehrlicher I downloaded the fontawesome.ttf file from here and my code works fine now.
I don't know why Font Awesome 5 Free-Solid-900.otf didn't work for me, but the fontawesome used in the posted link project, works for my project.
I really thank you for you help. Your provided codes helped me a lot.
Best regards.