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. font weights don't seem to change
Forum Updated to NodeBB v4.3 + New Features

font weights don't seem to change

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
9 Posts 2 Posters 936 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #1

    Hi all -

    This code:

      Column {
          Text {
            font.family: 'roboto'
            font.pixelSize: 24
            font.weight: Font.Normal
            text: "this is an example of roboto with Font.Normal."
          }
          Text {
            font.family: 'roboto'
            font.pixelSize: 24
            font.weight: Font.Medium
            text: "this is an example of roboto with Font.Medium."
          }
          Text {
            font.family: 'roboto'
            font.pixelSize: 24
            font.weight: Font.DemiBold
            text: "this is an example of roboto with Font.DemiBold."
          }
          Text {
            font.family: 'roboto'
            font.pixelSize: 24
            font.weight: Font.Bold
            text: "this is an example of roboto with Font.Bold."
          }
    }
    

    Produces this:

    fonts.PNG

    Only two weights seem to be visible. Any ideas what's going wrong?

    Thanks...

    5.14.2, BTW.

    fcarneyF 1 Reply Last reply
    0
    • mzimmersM mzimmers

      Hi all -

      This code:

        Column {
            Text {
              font.family: 'roboto'
              font.pixelSize: 24
              font.weight: Font.Normal
              text: "this is an example of roboto with Font.Normal."
            }
            Text {
              font.family: 'roboto'
              font.pixelSize: 24
              font.weight: Font.Medium
              text: "this is an example of roboto with Font.Medium."
            }
            Text {
              font.family: 'roboto'
              font.pixelSize: 24
              font.weight: Font.DemiBold
              text: "this is an example of roboto with Font.DemiBold."
            }
            Text {
              font.family: 'roboto'
              font.pixelSize: 24
              font.weight: Font.Bold
              text: "this is an example of roboto with Font.Bold."
            }
      }
      

      Produces this:

      fonts.PNG

      Only two weights seem to be visible. Any ideas what's going wrong?

      Thanks...

      5.14.2, BTW.

      fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      @mzimmers Is this something the font has to explicitly support?

      C++ is a perfectly valid school of magic.

      mzimmersM 1 Reply Last reply
      0
      • fcarneyF fcarney

        @mzimmers Is this something the font has to explicitly support?

        mzimmersM Offline
        mzimmersM Offline
        mzimmers
        wrote on last edited by
        #3

        @fcarney said in font weights don't seem to change:

        @mzimmers Is this something the font has to explicitly support?

        Not sure I understand the question -- if the font doesn't support the weighting, how else would it be implemented?

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          Seems to be relevant to available fonts and what they support. No idea how this is determined.

          Column {
                  id: fontcolumn
          
                  anchors.right: parent.right
          
                  //property string fontFam: 'roboto'
                  property string fontFam: "Helvetica"
          
                  Text {
                      font.family: parent.fontFam
                      font.pixelSize: 24
                      font.weight: Font.Normal
                      text: "this is an example of roboto with Font.Normal."
                  }
                  Text {
                      font.family: parent.fontFam
                      font.pixelSize: 24
                      font.weight: Font.Medium
                      text: "this is an example of roboto with Font.Medium."
                  }
                  Text {
                      font.family: parent.fontFam
                      font.pixelSize: 24
                      font.weight: Font.DemiBold
                      text: "this is an example of roboto with Font.DemiBold."
                  }
                  Text {
                      font.family: parent.fontFam
                      font.pixelSize: 24
                      font.weight: Font.Bold
                      text: "this is an example of roboto with Font.Bold."
                  }
              }
          
              ListView {
                  anchors.top: fontcolumn.bottom
                  anchors.bottom: parent.bottom
                  anchors.right: parent.right
          
                  width: 200
          
                  model: Qt.fontFamilies()
          
                  delegate: Item {
                      height: 40;
                      width: ListView.view.width
                      Text {
                          text: modelData;
                          MouseArea {
                              anchors.fill: parent
                              onClicked: {
                                  fontcolumn.fontFam = modelData
                              }
                          }
                      }
                  }
              }
          

          You will need to re-anchor these Items to see this correctly. It gives you a list of available fonts and selects them when you click on the font name in the list.

          C++ is a perfectly valid school of magic.

          mzimmersM 1 Reply Last reply
          0
          • fcarneyF fcarney

            Seems to be relevant to available fonts and what they support. No idea how this is determined.

            Column {
                    id: fontcolumn
            
                    anchors.right: parent.right
            
                    //property string fontFam: 'roboto'
                    property string fontFam: "Helvetica"
            
                    Text {
                        font.family: parent.fontFam
                        font.pixelSize: 24
                        font.weight: Font.Normal
                        text: "this is an example of roboto with Font.Normal."
                    }
                    Text {
                        font.family: parent.fontFam
                        font.pixelSize: 24
                        font.weight: Font.Medium
                        text: "this is an example of roboto with Font.Medium."
                    }
                    Text {
                        font.family: parent.fontFam
                        font.pixelSize: 24
                        font.weight: Font.DemiBold
                        text: "this is an example of roboto with Font.DemiBold."
                    }
                    Text {
                        font.family: parent.fontFam
                        font.pixelSize: 24
                        font.weight: Font.Bold
                        text: "this is an example of roboto with Font.Bold."
                    }
                }
            
                ListView {
                    anchors.top: fontcolumn.bottom
                    anchors.bottom: parent.bottom
                    anchors.right: parent.right
            
                    width: 200
            
                    model: Qt.fontFamilies()
            
                    delegate: Item {
                        height: 40;
                        width: ListView.view.width
                        Text {
                            text: modelData;
                            MouseArea {
                                anchors.fill: parent
                                onClicked: {
                                    fontcolumn.fontFam = modelData
                                }
                            }
                        }
                    }
                }
            

            You will need to re-anchor these Items to see this correctly. It gives you a list of available fonts and selects them when you click on the font name in the list.

            mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #5

            @fcarney interesting...on my system, none of the available fonts produced more than 2 distinct weights; some only showed 1. Is this consistent with your findings?

            fcarneyF 1 Reply Last reply
            0
            • mzimmersM mzimmers

              @fcarney interesting...on my system, none of the available fonts produced more than 2 distinct weights; some only showed 1. Is this consistent with your findings?

              fcarneyF Offline
              fcarneyF Offline
              fcarney
              wrote on last edited by
              #6

              @mzimmers I think I saw one with 3 diff values. The rest were 2.

              C++ is a perfectly valid school of magic.

              1 Reply Last reply
              0
              • mzimmersM Offline
                mzimmersM Offline
                mzimmers
                wrote on last edited by
                #7

                So, this is an area I know little about; who is to "blame" for the lack of more weight options?

                1 Reply Last reply
                0
                • fcarneyF Offline
                  fcarneyF Offline
                  fcarney
                  wrote on last edited by
                  #8

                  I suspect if you provided ttf font it might work better. No idea if the system fonts are ttf. Also, adding fonts in Windows is a pain as you have to install them I suppose you could hide a font in a qrc resource. But Windows does weird things with fonts I don't completely understand.

                  C++ is a perfectly valid school of magic.

                  1 Reply Last reply
                  0
                  • mzimmersM Offline
                    mzimmersM Offline
                    mzimmers
                    wrote on last edited by
                    #9

                    I'm running on Linux (actually WSL)...that might be part of the problem, though you said it wasn't working for you, either.

                    So, do I infer correctly that there's a process for manually adding fonts to Qt?

                    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