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. Linux .ini resource file and font specification
QtWS25 Last Chance

Linux .ini resource file and font specification

Scheduled Pinned Locked Moved Unsolved General and Desktop
debianfontsettingsqt5.12
4 Posts 2 Posters 570 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.
  • B Offline
    B Offline
    Basile_Starynkevitch
    wrote on last edited by Basile_Starynkevitch
    #1

    Hello,

    This is in the context of the GPLv3+ RefPerSys "research" project (see these slides for motivation) on Linux only (either Debian/Sid/x86-64 on a AMD Ryzen Threadripper 2970WX desktop or Maegia 7/x86-64 on a i7 ACER Nitro 5 laptop). The audience of RefPerSys is only Linux developers interested in reflexive systems for artificial intelligence (not any kind of general user). The object model of RefPerSys -which can also be seen as an object oriented reflexive language implementation- claims to be more general than even the Qt meta object protocol (but inspired by it and by ObjVLisp). The source code is on https://gitlab.com/bstarynk/refpersys and I am referring to commit d6b4b1bba06fc57d51e0b91.

    Qt version is Qt5.12.5 as packed in Debian/Sid. i.e the following Debian package

    libqt5widgets5:amd64 5.12.5+dfsg-10 amd64        Qt 5 widgets module
    

    and corresponding development packages, explained in our README. On the desktop the Xorg server is the package:

    xorg           1:7.7+20     amd64        X.Org X Window System
    

    More details about the context on our issue#30 and in this and following archived emails, in particular this one.

    So, we are running (in our file windows_qrps.cc line 73) the following C++ code (compiled with GCC g++ 9.3 from Debian/Sid):

    QSettings* qst = RpsQApplication::qt_settings();
    RPS_ASSERT(qst);
    constexpr const char*label_setting_name = "window_label_font";
    RPS_DEBUG_LOG(GUI, "RpsQWindow::RpsQWindow settings path: "
                  << qst->fileName().toStdString() << " "
                  << ((qst->contains(QString(label_setting_name)))?"has":"without")
                  << " "
                  << label_setting_name);
    QFont label_font = qst->value(label_setting_name).value<QFont>();
    int label_fontsize = label_font.pointSize();
    int label_minheight = (label_fontsize)>2?((4*label_fontsize)/3+1):10;
    int label_maxheight = (label_fontsize)>2?(2*label_fontsize):24;
    if (label_maxheight <= label_minheight+2)
      label_maxheight = (9*label_minheight)/8+1;
    RPS_DEBUG_LOG(GUI, "RpsQWindow::RpsQWindow " << label_setting_name << ":=" << label_font.toString().toStdString()
                  << ", label_fontsize=" << label_fontsize
                  << ", label_minheight=" << label_minheight
                  << ", label_maxheight=" << label_maxheight);
    

    where RPS_ASSERT and RPS_DEBUG_LOG are our macros (defined in our file refpersys.hh ) and doing what their name suggests (debugging logs happens via some std::ostringstream)

    We have one QSettings-managed resource file, our .qt-refpersys.ini file starting with:

    # default RefPerSys Qt settings
    # see http://refpersys.org/ and https://doc.qt.io/qt-5/qsettings.html
    # file refpersys/.qt-refpersys.ini
    
    ## the font for windows label
    window_label_font=Bitstream Vera Sans,12
    

    We don't understand what is the expected syntax for QFont-s settings (on Linux)

    At runtime, we do observe (even with strace) that our resource file .qt-refpersys.ini is loaded, and the debugging messages indeed show

    ** RefPerSys INFORM! appli_qrps.cc:766:: void rps_run_application(int&, char**) running the GUI since no batch mode
    RPS DEBUG    GUI <rps-main:407158> @window_qrps.cc:76 10:03:12.96 
    RpsQWindow::RpsQWindow settings path: /home/basile/refpersys/.qt-refpersys.ini has window_label_font
    RPS DEBUG 0000 ~ 2020-May-05@10:03:1588665792.96 MEST *^*^*
    RPS DEBUG    GUI <rps-main:407158> @window_qrps.cc:87 10:03:12.96 
    RpsQWindow::RpsQWindow window_label_font:=Sans,9,-1,5,50,0,0,0,0,0, label_fontsize=9, label_minheight=13, label_maxheight=18
    
    

    But why is the window_label_font a Sans font, given that we specified a Bitstream Vera Sans,12 and why is its size 9, but we want 12 points?

    Visually, the displayed font at runtime is not what we want. See attached images in our issue#26

    What am I doing wrong?

    Regards.

    PS. I don't care at all about portability to non-Linux Qt5 systems.

    --
    Basile Starynkevitch http://starynkevitch.net/Basile/index_en.html
    near Paris, France basile@starynkevitch.net

    Basile Starynkevitch <basile@starynkevitch.net>
    (only mine opinions / les opinions sont miennes uniquement)
    92340 Bourg-la-Reine, France
    web page: starynkevitch.net/Basile/
    See/voir: https://github.com/RefPerSys/RefPerSys

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You want to read the font name as QString, not as QFont since you store it as a string in your ini file.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      B 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        You want to read the font name as QString, not as QFont since you store it as a string in your ini file.

        B Offline
        B Offline
        Basile_Starynkevitch
        wrote on last edited by Basile_Starynkevitch
        #3

        @Christian-Ehrlicher
        but how should I convert that string to a loaded QFont? And how should I check that the font does exist on the running system?

        BTW, the .qt-refpersys.ini file is handwritten using emacs; I would prefer to avoid writing it programmatically.

        Basile Starynkevitch <basile@starynkevitch.net>
        (only mine opinions / les opinions sont miennes uniquement)
        92340 Bourg-la-Reine, France
        web page: starynkevitch.net/Basile/
        See/voir: https://github.com/RefPerSys/RefPerSys

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          When you don't want to let save it by Qt you have to read the font attributes one by one from your ini file and then construct it with the QFont ctor

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1

          • Login

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