Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Loading custom fonts on iOS
Forum Updated to NodeBB v4.3 + New Features

Loading custom fonts on iOS

Scheduled Pinned Locked Moved Mobile and Embedded
14 Posts 6 Posters 8.5k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    bercik
    wrote on 20 Dec 2013, 12:01 last edited by
    #5

    Thank you very much! I will give it a try.

    hint: if you want to use custom .plist file you can place one in your project directory and add following line to your .pro file

    QMAKE_INFO_PLIST = MyApp.plist

    Cheers

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jraichouni
      wrote on 2 Jan 2014, 22:42 last edited by
      #6

      Hope it is going to be implemented in Qt 5.2.1;-)

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bercik
        wrote on 7 Jan 2014, 06:47 last edited by
        #7

        Yeah, would be great :)

        ...but for now solution given by dbrian works like a charm, thanks for that.

        P.S. i haven't used resource file, just plain ttf and it worked without using font loader, i've just listed all available font families by

        @
        QFontDatabase db;
        foreach (const QString &family, db.families()) {
        qDebug() << family;
        }
        @

        ...and picked my custom font's family name

        Cheers

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jraichouni
          wrote on 7 Jan 2014, 08:16 last edited by
          #8

          Will give it a try in the evening

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jraichouni
            wrote on 8 Jan 2014, 02:15 last edited by
            #9

            Tried it.

            In the .pro file I added:

            @
            ios: {
            fonts.files = ../../src/qml/fonts/SourceCodePro-Regular.ttf
            fonts.path = .fonts
            QMAKE_BUNDLE_DATA += fonts
            }
            @

            On the iOS device or simulator QFontDatabase db.families() contains an entry "Source Code Pro" and the .ttf file got copied to the corresponding application sandbox sub directory .fonts

            But the console logs as you described
            @
            This plugin does not support application fonts
            qrc:///qml/main.qml:12:5: QML FontLoader: Cannot load font: "qrc:///qml/fonts/SourceCodePro-Regular.ttf"
            @

            main.qml lists

            @
            FontLoader { id: sourceCodeProFont; source: "fonts/SourceCodePro-Regular.ttf" }
            @

            main.qml has been launched via qrc

            @
            view->setSource(QUrl("qrc:///qml/main.qml"));
            @

            My Info.plist contains

            @
            <key>UIAppFonts</key>
            <array>
            <string>.fonts/SourceCodePro-Regular.ttf</string>
            </array>
            @

            Therefore, it seems as if one can not load a custom font!?

            It would help to be able to have a .qml in the qrc system but define a file url as source of FontLoader instead of a qrc url in the .qml

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bercik
              wrote on 8 Jan 2014, 06:23 last edited by
              #10

              Hi Jamil,
              please try to remove FontLoader from qml completely, in my case that was a problem.If your font is present in QFontDatabase, just use font's family name while defining item in qml, i.e.:

              @
              Text {
              anchors.centerIn: ......
              text: ......
              color: "#ffffffff"
              font.family: "Source Code Pro"
              font.pointSize: 20
              }
              @

              Cheers

              1 Reply Last reply
              0
              • J Offline
                J Offline
                julienw
                wrote on 23 Mar 2014, 13:51 last edited by
                #11

                Just to precise something :There is no need to have a script for changing the plist file :

                Add "QMAKE_INFO_PLIST = AppliInfo.plist" in the .pro in order to use your own plist file.

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  bercik
                  wrote on 24 Mar 2014, 05:59 last edited by
                  #12

                  yup, see my post from 20 Dec

                  Cheers

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    julienw
                    wrote on 24 Mar 2014, 08:40 last edited by
                    #13

                    Oops yes. Sorry ^^

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      alexleutgoeb
                      wrote on 2 Apr 2014, 18:31 last edited by
                      #14

                      For the sake of completeness, it seems like FontLoader is fully implemented for iOS as of the current "Qt 5.3 beta":http://blog.qt.digia.com/blog/2014/03/25/qt-5-3-beta-released/, so there are no more hacks required. ;)

                      Cheers,
                      Alex

                      1 Reply Last reply
                      0

                      • Login

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