Menu

#2476 font problem on qt terminal on windows

None
open
nobody
2023-03-15
2021-12-16
Anonymous
No

This ticket was discussed in gnuplot-beta mailing list.
https://sourceforge.net/p/gnuplot/mailman/gnuplot-beta/thread/939389966.104818.1639686635334.JavaMail.yahoo%40mail.yahoo.co.jp/#msg37402693

qt terminal on windows gives incorrect plot.

Ethan states that in the above mail,

That is evidence of a font problem.
The jitter algorithm calculates displacement in terms of
horizontal character width, which is obtained from the font
metrics. If the font incorrectly reports the width, then
all of the jitter displacements are too big or too small.

I am a bit surprised that the wxt terminal doesn't show the
same problem. On linux, both qt and wxt use the same font
mechanism. But perhaps this isn't the case on Windows.

If I recall correctly, you can configure wxWidgets to use
different system back-ends. If you can figure out what
configuration option wxt is using to get correct font metrics,
maybe we can persuade qt to use that same mechanism.

Screen shot on windows, wxt, and qt terminals of jitter.dem are attached.

3 Attachments

Discussion

  • Tatsuro MATSUOKA

     
  • Tatsuro MATSUOKA

    If I recall correctly, you can configure wxWidgets to use
    different system back-ends. If you can figure out what
    configuration option wxt is using to get correct font metrics,

    In the gnuplot-beta ML, I completely misled the above statement.
    Do you mean that I can build wxWidgets with different option concerning font in the process of configure ?

     

    Last edit: Tatsuro MATSUOKA 2021-12-17
    • Ethan Merritt

      Ethan Merritt - 2021-12-17

      I know that on Mac OS you can configure wxWidgets either to use gtk+cairo (as on linux) or to use cocoa (a toolkit specific to Mac). I do not know whether Windows offers a similar choice between gtk+cairo and something else that is Windows-specific.

      I also do not know how gtk on Windows accesses fonts.

      Perhaps you can do this:
      - build gnuplot with the wxt terminal but without the qt terminal
      - confirm that fonts work correctly in the wxt terminal
      - inspect the gnuplot binary to see if it links to a font library

      For example, on linux

      [~/git/gnuplot/src] ldd gnuplot | grep font
              libfontconfig.so.1 => /lib64/libfontconfig.so.1 (0x00007f1218960000)
      

      This tells me that gnuplot is using the fontconfig library. I think that it uses this same library for both the qt and the wxt terminals ( but I am not 100% sure!). What do you see on Windows? Is there some other library that it uses instead when no qt terminal is configured?

       
      • Bastian Märkisch

        cairo terminals (including wxt) on Windows use the native font mechanism, just like the windows terminal. The cairo terminals can be configured to use fontconfig instead. As there's no "global" fontconfig mechanism, this is somewhat error prone as it needs to refresh its own local database leading to slow-downs and fonts occasionally not being found. This is likely an configuration file issue, but I haven't been able to figure it out yet.

        qt ( at least the one from MSYS2/Mingw-64 which I use) uses fontconfig, and there we still have the issue of "slow font init" on the first plot on some machines. (I don't think recompiling Qt or cairo/pango is not a viable option (on Windows) due to the large number of dependencies. Please also note that wxt uses wxWidgets for the user interface, but all drawing is done by cairo/pango. On Windows, wxWidgets does not use GTK but a native backend MSW).

        Instead, I suggest to finally try to figure out what is wrong with our local fontconfig configuration.

         
  • Bastian Märkisch

    Tatsuro, have you tried using a different font set term qt font "Arial". I suggest trying to use one of the default Windows fonts like Tahoma, Arial, Calibri, etc... For cairo terminals, we changed the default from "Sans" to "Tahoma" at one point. From gp_cairo.c:

    /* BM: New function to determine the default font.
     * On Windows, the "Sans" alias normally is equivalent to
     * "Tahoma" but the resolution fails on some systems. */
    
     
    • Bastian Märkisch

      FWIW, works fine here.

       
  • Tatsuro MATSUOKA

    Bastian
    I tried use "set term qt font 'arial' " before loading script files and strange behaviors are disappeared.
    Thanks!

    Initial font used in qt terminal seemed to be not registered in the fontconfig. Adding the font information to local.conf and executing "fc-cache -fv" will solve the problem. Some applications like GNU octave register fonts into fontconfig using fc-cache in the installer.

     

    Last edit: Tatsuro MATSUOKA 2021-12-22
  • Bastian Märkisch

    • labels: --> Windows, qt, fontconfig
     
  • Tatsuro MATSUOKA

    On current windows (10 or 11 22H2) , problems do not appear even if I do not set font name (e.g. set term qt but not set term qt font "Arial").

     

    Last edit: Tatsuro MATSUOKA 2023-03-15

Log in to post a comment.