Skip to content

A library to ease up Font-Awesome handling in QML + a viewer for programmers: Find a glyph and simply copy its ID into your code.

License

Notifications You must be signed in to change notification settings

zmaibbs7/fontawesome-qml

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fontawesome-qml

Font-Awesome is a project that deserves its name ❤️. Since it cannot be expected on distros to be installed, using it in (QML-) projects is a bit tedious. One needs to:

  • Get the ttf's into your QML's project resource
  • register the fonts
  • search for the glyphs wanted
  • find a more descripitive way than unicode chars to add icons to the code

To make things more simple this project contains:

  • a wrapper library that translates symbolic variable names to unicode and adds a tiny helper function to colorize glyphs
  • A viewer-application Screenshot_2020-08-15_21-02-51 to search for glyphs and directly copy symbol name into QML-source code.
  • A python-script to auto-upgrade symbol-list/model to latest Font-Awesome.

To use this project do

  1. Download it by git clone --recursive https://github.com/schnitzeltony/fontawesome-qml.git
  2. Build it and install it to a location cmake can find it

In your project add:

  1. In CMakeList.txt:
...
find_package(FontAweSomeQml REQUIRED)
...
target_link_libraries(<your-target>
...
        FontAweSomeQml::FontAweSomeQml
...
)
  1. In main.cpp (for parameters of FontAwesomeQml::registerFonts see fontawesome-qml.h)
#include <fontawesome-qml.h>
...
int main(int argc, char *argv[])
{
    QQmlApplicationEngine engine;
    ...
    FontAwesomeQml::registerFonts(false, true, false);
    FontAwesomeQml::registerFAQml(&engine);
    ...
    engine.load(url);
    return app.exec();
}
  1. In QML:
...
import FontAwesomeQml 1.0
...
    Button {
        font.family: FAQ.fontFamily
        font.styleName: "Solid" // or "Regular" requires registerFonts(true, ..)
        text: FAQ.fa_file
    }
...
  1. In QML / ListElement we cannot useFAQ.<glyph>

ListElement: cannot use script for property value

see Example:

...
import FontAwesomeQml 1.0
import FontAwesomeHash 1.0
...
ListView {
    ListModel {
        ListElement {glyph: "fa_moon"; gcolor: "black"; gtext: "Sleep well"}
        ListElement {glyph: "fa_sun"; gcolor: "yellow"; gtext: "Most favorite"}
        ...
    }
    delegate: Text {
        font.family: FAQ.fontFamily
        text: FAQ.icon(FAQH.strToGlyph(glyph), gcolor) + gtext
   }
}
...

For dependencies check CMakeLists.txt / find_package.


THE CODE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND and licensed under LGPL-3.0 License.

About

A library to ease up Font-Awesome handling in QML + a viewer for programmers: Find a glyph and simply copy its ID into your code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • QML 77.2%
  • C++ 19.5%
  • CMake 1.7%
  • Python 1.6%