Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to add barcode font (Code128.ttf and Code39.ttf) to application?
QtWS25 Last Chance

How to add barcode font (Code128.ttf and Code39.ttf) to application?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 648 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MHermann
    wrote on 20 Sept 2021, 12:04 last edited by MHermann
    #1

    Hello,
    is it possible to add Code128.ttf and Code39.ttf to my Qt application? I am using Qt5.12.7.
    For example I want to show a text as code128 or code39 barcode in a label.
    But at the moment I am not able to load the fonts.
    I tried it with

    QFontDatabase::addApplicationFont(":/fonts/code128.ttf");
    

    and with

    FontLoader {
       id: code128font
       source: "qrc:/fonts/code128.ttf"
    }
    

    But it didn't work. I always get an error, that font could not be loaded.

    Any suggestions?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Sept 2021, 18:38 last edited by
      #2

      Hi,

      Does it work if you use the full path to the font file ?
      What value does the call to addApplicationFont return ?
      On which OS are you running your application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MHermann
        wrote on 21 Sept 2021, 05:16 last edited by MHermann
        #3

        Yes, when I add one font and use the full path it works.

        But I want to add the ttf files to my ressources and use it with a relative path.
        Is that possbile?
        At the moment the ttf files are located in a sub folder in the application folder.
        Then I added the files to qrc file and use the path from there.

        For information:
        I am developing on Ubuntu 18.04. Then the application is cross compiled and runs raspbian buster.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 21 Sept 2021, 19:47 last edited by
          #4

          Are you sure your paths are correct with regard to your folder structure ?
          Did you set any alias in the qrc file ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply 22 Sept 2021, 12:31
          0
          • S SGaist
            21 Sept 2021, 19:47

            Are you sure your paths are correct with regard to your folder structure ?
            Did you set any alias in the qrc file ?

            M Offline
            M Offline
            MHermann
            wrote on 22 Sept 2021, 12:31 last edited by
            #5

            @SGaist: Now I used the correct resource path of the fonts. Now its working. Don't know what my problem was ...

            1 Reply Last reply
            0

            4/5

            21 Sept 2021, 19:47

            • Login

            • Login or register to search.
            4 out of 5
            • First post
              4/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved