Git Product home page Git Product logo

Comments (10)

laserpants avatar laserpants commented on May 12, 2024

The font files should be bundled with the library as resources.

See components/resources.qrc:

<RCC>
    <qresource prefix="/fonts">
        <file>../fonts/Roboto/Roboto-Black.ttf</file>
        <file>../fonts/Roboto/Roboto-Bold.ttf</file>
        <file>../fonts/Roboto/Roboto-Medium.ttf</file>
        <file>../fonts/Roboto/Roboto-Regular.ttf</file>
        <file>../fonts/Roboto/Roboto-Light.ttf</file>
        <file>../fonts/Roboto/Roboto-Thin.ttf</file>
    </qresource>
...

These are then loaded by the style class (QtMaterialStyle). See qtmaterialstyle.cpp, line 23:

    QFontDatabase::addApplicationFont(":/material/fonts/Roboto/Roboto-Regular.ttf");
    QFontDatabase::addApplicationFont(":/material/fonts/Roboto/Roboto-Medium.ttf");
    QFontDatabase::addApplicationFont(":/material/fonts/Roboto/Roboto-Bold.ttf");

from qt-material-widgets.

laserpants avatar laserpants commented on May 12, 2024

I don't have the font installed on my system, no.

from qt-material-widgets.

fperillo avatar fperillo commented on May 12, 2024

I used the unix switch for grep on a windows workstation... no dir recursion... sorry about this.

This evening I will try on my home notebook, and will try this code snippet to see what happens with the fonts:
https://bugreports.qt.io/browse/QTBUG-61520

I still think that setPointSize call should not be necessary it the correct font is returned from the FontDatabase.

from qt-material-widgets.

fperillo avatar fperillo commented on May 12, 2024

I confirm there is a problem with the font loading.
which-is-roboto
Which one is Roboto?

I think the problem is in the resource file... I'm not even sure you are using roboto font due to a mismatch in the path name...
QFontDatabase::addApplicationFont(":/material/fonts/Roboto/Roboto-Regular.ttf");

See the changes in the respource file:
fperillo@1bfb999
and where I add the fonts using the aliases

from qt-material-widgets.

laserpants avatar laserpants commented on May 12, 2024

What if you put the fonts in the same directory as the icons? I mean, just copy the whole fonts directory into components/ and then change the path in the resource file from ../fonts/Roboto to fonts/Roboto.

from qt-material-widgets.

laserpants avatar laserpants commented on May 12, 2024

The resource path is not a one-to-one mapping to the file system path, because of how the resource system works in Qt. See http://doc.qt.io/qt-5/resources.html. (The IDE complains if I try to use an incorrect resource path.)

from qt-material-widgets.

laserpants avatar laserpants commented on May 12, 2024

I'll try on a different machine also when I get the chance, to see if I can figure out what the problem is.

from qt-material-widgets.

fperillo avatar fperillo commented on May 12, 2024

An alias should be used in the resource file, in this way:
../fonts/Roboto/Roboto-Medium.ttf

then load in this way:
QFontDatabase::addApplicationFont( ":/fonts/rmedium" );

This is an official way to load resources via aliases.

I then created font via:
QFont font("Roboto", 14, iFontWeight )
where f.e.
iFontWeight = QFont::Bold

from qt-material-widgets.

laserpants avatar laserpants commented on May 12, 2024

Ok, I think I understand now. Does 2ee5d6d work or?

from qt-material-widgets.

fperillo avatar fperillo commented on May 12, 2024

It works now :-)

Thank you

from qt-material-widgets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.