Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Where should I put my fonts?
Forum Updated to NodeBB v4.3 + New Features

Where should I put my fonts?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 528 Views 2 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.
  • C Offline
    C Offline
    Creaperdown
    wrote on last edited by
    #1

    My application comes with non-default fonts that I want to install on the users PC. Until now I have been installing the fonts to a folder in the user's home directory (linux) but since my application is available in /usr/bin I'd like it to be in a location where all users can load the fonts from.

    Is there one folder that I can install my fonts to that works across all linux distros? If so, where is that? Also, is there a similar folder where I can install my fonts to for windows?

    If I'd install my fonts to these common locations (e.g. /usr/fonts), would QFontDatabase automatically pick it up, or would I need to manually check what OS I am on and then use (e.g. on linux) `QFontDatabase::addApplicationFont("/usr/fonts/myFont.otf")?

    M 1 Reply Last reply
    0
    • C Creaperdown

      My application comes with non-default fonts that I want to install on the users PC. Until now I have been installing the fonts to a folder in the user's home directory (linux) but since my application is available in /usr/bin I'd like it to be in a location where all users can load the fonts from.

      Is there one folder that I can install my fonts to that works across all linux distros? If so, where is that? Also, is there a similar folder where I can install my fonts to for windows?

      If I'd install my fonts to these common locations (e.g. /usr/fonts), would QFontDatabase automatically pick it up, or would I need to manually check what OS I am on and then use (e.g. on linux) `QFontDatabase::addApplicationFont("/usr/fonts/myFont.otf")?

      M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      @Creaperdown
      You can embed your font as a resource in your app.

      C 1 Reply Last reply
      0
      • M mpergand

        @Creaperdown
        You can embed your font as a resource in your app.

        C Offline
        C Offline
        Creaperdown
        wrote on last edited by
        #3

        @mpergand Do I simply put them into a resource file and add them to my binary?

        M 1 Reply Last reply
        0
        • C Creaperdown

          @mpergand Do I simply put them into a resource file and add them to my binary?

          M Offline
          M Offline
          mpergand
          wrote on last edited by mpergand
          #4

          @Creaperdown said in Where should I put my fonts?:

          @mpergand Do I simply put them into a resource file and add them to my binary?

          Yes.
          The path must begin with :/...

          C 1 Reply Last reply
          0
          • M mpergand

            @Creaperdown said in Where should I put my fonts?:

            @mpergand Do I simply put them into a resource file and add them to my binary?

            Yes.
            The path must begin with :/...

            C Offline
            C Offline
            Creaperdown
            wrote on last edited by
            #5

            @mpergand and how would I add it to the QFontDatabase? Would I pass e.g. QFontDatabase::addApplicationFont("qrc:/resources/myFont.otf") to it, or wouldn't I need to add it anymore at all?

            M 1 Reply Last reply
            0
            • C Creaperdown

              @mpergand and how would I add it to the QFontDatabase? Would I pass e.g. QFontDatabase::addApplicationFont("qrc:/resources/myFont.otf") to it, or wouldn't I need to add it anymore at all?

              M Offline
              M Offline
              mpergand
              wrote on last edited by mpergand
              #6

              @Creaperdown
              I'm using this:

              int id=QFontDatabase::addApplicationFont(path);
                if(id EQ -1)
                    {QTLog(<<"UI Font not found"<<path)
                    return -1;
                    }
              
              C 1 Reply Last reply
              0
              • M mpergand

                @Creaperdown
                I'm using this:

                int id=QFontDatabase::addApplicationFont(path);
                  if(id EQ -1)
                      {QTLog(<<"UI Font not found"<<path)
                      return -1;
                      }
                
                C Offline
                C Offline
                Creaperdown
                wrote on last edited by
                #7

                @mpergand What is path for you? Is it something like "qrc:/path/to/fonts/myFont.otf")?

                M 1 Reply Last reply
                0
                • C Creaperdown

                  @mpergand What is path for you? Is it something like "qrc:/path/to/fonts/myFont.otf")?

                  M Offline
                  M Offline
                  mpergand
                  wrote on last edited by
                  #8

                  @Creaperdown said in Where should I put my fonts?:

                  @mpergand What is path for you? Is it something like "qrc:/path/to/fonts/myFont.otf")?

                  ":/Fonts/Regular.ttf"
                  ":/Fonts/Medium.ttf"
                  ":/Fonts/Bold.ttf"

                  All my fonts are in the same folder named "Fonts"

                  C 1 Reply Last reply
                  1
                  • M mpergand

                    @Creaperdown said in Where should I put my fonts?:

                    @mpergand What is path for you? Is it something like "qrc:/path/to/fonts/myFont.otf")?

                    ":/Fonts/Regular.ttf"
                    ":/Fonts/Medium.ttf"
                    ":/Fonts/Bold.ttf"

                    All my fonts are in the same folder named "Fonts"

                    C Offline
                    C Offline
                    Creaperdown
                    wrote on last edited by
                    #9

                    @mpergand Thank you, I will try to do it the same way.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Creaperdown
                      wrote on last edited by
                      #10

                      Embedding the fonts worked perfectly well. Thank you!

                      1 Reply Last reply
                      0
                      • C Creaperdown has marked this topic as solved on

                      • Login

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