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. Get the writing system for the application font?
Qt 6.11 is out! See what's new in the release blog

Get the writing system for the application font?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.5k 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote on last edited by
    #1

    I have created my own font combo box class because I needed more control over the fonts displayed. This is for an application which is designed to be i18l ready.

    However, I need to populate the list of font families according to the desired writing system (enum values as defined in QFontDatabase), otherwise I get dozens, if not hundreds, of symbol fonts and fonts in many different languages which can be tiresome to scroll through.

    Is there a way to do this by querying some system info? I can just define QFontDatabase::Latin, for example, as a constant in my code, but what if someone wants to use the app with some language which uses a non-Latin writing system? I want to avoid having to change the source code, if possible, and query the information at runtime.

    Pl45m4P 1 Reply Last reply
    0
    • R Robert Hairgrove

      I have created my own font combo box class because I needed more control over the fonts displayed. This is for an application which is designed to be i18l ready.

      However, I need to populate the list of font families according to the desired writing system (enum values as defined in QFontDatabase), otherwise I get dozens, if not hundreds, of symbol fonts and fonts in many different languages which can be tiresome to scroll through.

      Is there a way to do this by querying some system info? I can just define QFontDatabase::Latin, for example, as a constant in my code, but what if someone wants to use the app with some language which uses a non-Latin writing system? I want to avoid having to change the source code, if possible, and query the information at runtime.

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Robert-Hairgrove

      Just filter your font list by using
      https://doc.qt.io/qt-5/qfontdatabase.html#families

      then populate your comboBox with your filtered list.

      To add more families with different wrinting systems at runtime, you could add checkBoxes and add the according families to your list (and to your font comboBox).


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      R 1 Reply Last reply
      0
      • Pl45m4P Pl45m4

        @Robert-Hairgrove

        Just filter your font list by using
        https://doc.qt.io/qt-5/qfontdatabase.html#families

        then populate your comboBox with your filtered list.

        To add more families with different wrinting systems at runtime, you could add checkBoxes and add the according families to your list (and to your font comboBox).

        R Offline
        R Offline
        Robert Hairgrove
        wrote on last edited by
        #3

        @Pl45m4 Thanks, but I am doing this already. The issue is WHICH filter to use, decided at runtime?

        I suppose I could hard-code a lookup table depending on the current language, but it would be much easier to get this information directly from the operating system language, or include it in the configuration file (there will never be more than a few languages, anyway).

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Robert Hairgrove
          wrote on last edited by
          #4

          Now I am going ahead by adding an attribute to the configuration file which explicitly matches the writing system with any language which can be selected. The user can change the language as well as the application font in the settings dialog. If the current font is compatible with the new language selected, it will continue to be used; otherwise, the system font will be used, and the user will be prompted to choose a different font if so desired.

          It would be better to query the system for an appropriate writing system, however. Therefore, I am not marking this as solved just yet.

          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