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. Font styles issues in QFontDatabase
QtWS25 Last Chance

Font styles issues in QFontDatabase

Scheduled Pinned Locked Moved Unsolved General and Desktop
fontslocale
8 Posts 2 Posters 945 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.
  • S Offline
    S Offline
    SiO2
    wrote on 1 Aug 2020, 09:03 last edited by SiO2 8 Jun 2020, 18:20
    #1

    When I am generating style lists for my font picking widget, I get localised strings,

        QStringList familyBuf = dispSettings->fdb.families(QFontDatabase::Latin);
        for (int i = (familyBuf.length() - 1); i >= 0; i--)
            if (!dispSettings->fdb.isPrivateFamily(familyBuf.at(i)))
                if (dispSettings->fdb.isSmoothlyScalable(familyBuf.at(i)))
                    if (QFontInfo(QFont(familyBuf[i])).family() == familyBuf.at(i)) {
                        QString buf = familyBuf.at(i);
                        fontFamilies.append(buf);
                        stylesPack.insert(std::make_pair(buf, dispSettings->fdb.styles(buf)));
    

    but when I am trying to get current style from font via QFontInfo+QFontDatabase, to generate initial GUI state, I suddenly recieve non-localized style string.

     currStyle = dispSettings->fdb.styleString(fontInfo);
    

    In Windows 7+ Qt5.7 QFontDatabase generated non-localized font strings, so there was no issues. How do I work around this mismatch in the Qt5.15+?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 1 Aug 2020, 09:11 last edited by
      #2

      Hi
      Is this on win 7 + Qt5.15 ?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SiO2
        wrote on 1 Aug 2020, 09:37 last edited by
        #3

        Hi.
        No, the first system is w7+Qt5.7, the second is w10+Qt5.15.

        M 1 Reply Last reply 1 Aug 2020, 09:48
        0
        • S SiO2
          1 Aug 2020, 09:37

          Hi.
          No, the first system is w7+Qt5.7, the second is w10+Qt5.15.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 1 Aug 2020, 09:48 last edited by
          #4

          @SiO2
          Hi
          Would it be possible to try Qt5.7 on the win 10 to verify it is indeed something that changed
          from 5.7 to 5.15 and not something that changed from win 7 -> win 10 ?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SiO2
            wrote on 1 Aug 2020, 10:46 last edited by
            #5

            Checked w10+Qt5.7. It is Qt changes that cases issues.

            1 Reply Last reply
            1
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 1 Aug 2020, 10:51 last edited by
              #6

              Hi
              Ok so its either a bug (regression) or some changes in QFontInfo.
              I could not locate any change log for QFontInfo but maybe others have an idea.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SiO2
                wrote on 1 Aug 2020, 11:12 last edited by SiO2 8 Jan 2020, 17:17
                #7

                QFontInfo behave the same way in both Qt5.7 and Qt5.15. It is QFontDatabase gives localized style strings in the newer version. What I need is a way to extract stylestring from current font in a way matching QFontDatabase behaviour, i.e. localized one.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SiO2
                  wrote on 1 Aug 2020, 17:14 last edited by SiO2 8 Jan 2020, 17:18
                  #8

                  It is worse in fact

                  QFontDatabase::styleString(const QFontInfo &fontInfo) //"Normal"
                  

                  mismatch

                  QStringList QFontDatabase::styles(const QString &family)   //"Обычный", "Полужирный" 
                  

                  so this class essentially breaks its own logic. Also default font keeps those localized stylestring even after me giving up localization via

                  QLocale::setDefault(QLocale::English);
                  

                  std::map<QString, QStringList> stylesPack

                  1 Reply Last reply
                  0

                  2/8

                  1 Aug 2020, 09:11

                  6 unread
                  • Login

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