Menu

#2261 Text Size Depends on Windows Scale and Layout Setting

None
closed-fixed
nobody
2021-12-25
2020-05-12
Anonymous
No

I'm using gnuplot 5.2.8 on Windows 10. The text size in a plot changes, depending on Windows' "Scale and Layout" setting (under Settings, Display). Here's a simple script to demonstrate the problem:

set terminal pngcairo
set title "Windows 10 Display Scale and Layout = 100%"
set ylabel "Sin(x)"
set xlabel "x"
set output "test100.png"
plot sin(x)
set output

I've attached the output files that result from running this script with the Scale and Layout setting at 100%, 125%, 150% and 175%. The plot size stays the same, but the text size grows in proportion to the Scale and Layout setting, making the apperance of the plot entirely dependent on that setting. This doesn't seem right, and it makes it impossible to create a portable script for Windows 10 users because they might all have different Scale and Layout settings.

Aaron Zick
zick@zicktech.com

4 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2020-05-12

    I will probably not be able to help you with this since I'm not a Windows user, but I would like to understand more clearly what you are reporting. Are you saying that the text size chosen by the pngcairo terminal changes depending on the scale setting for the screen of the computer that gnuplot is run from? Or is it that the "Scale and Layout" setting is something that changes font handling for all programs on the system? Does this affect other gnuplot terminals besides pngcairo?

    Are you specifying a font size for the pngcairo terminal to use and it ignores that size, or are you not specifying a size at all and it is the default size that is changing?

     
  • Aaron Zick

    Aaron Zick - 2020-05-14

    Yes, the text size chosen by the pngcairo teminal changes, depending on the scale setting for the screen of the computer that gnuplot is run from. The "Scale and Layout" setting magnifies the display (not just text) of every window, the desktop, the task bar, etc. It shouldn't cause gnuplot to create different output files, though. The pdfcairo terminal is also affected. I haven't tried others.

    The example script is just the simplest one that demonstrates the problem. You can specify a font size or use the default. Either way, every text element gets magnified by the Scale and Layout setting, as though a fontscale multiplier (that you didn't request) was used.

     
  • Ethan Merritt

    Ethan Merritt - 2020-05-14

    The thing is -- gnuplot does not do its own font handling. It asks the system or support library for the chosen terminal to provide a font. So if pngcairo and pdfcairo are the terminals showing a problem, logically the problem is with cairo and that's where we should start looking. But to confirm this, could you also check non-cairo terminals, e.g. "set term jpeg" and "set term emf"?

     
  • Aaron Zick

    Aaron Zick - 2020-05-14

    The problem affects terminals pngcairo, pdfcairo, and pdf, but it does not affect terminals png, jpeg, or emf.

     
  • Bastian Märkisch

    • labels: --> Windows
    • Group: -->
    • Priority: -->
     
  • Bastian Märkisch

    • labels: Windows --> Windows, cairo
    • status: open --> pending-fixed
     
  • Bastian Märkisch

    The behaviour is correct for the wxt terminal, which displays on screen and uses the same cairo/pango-based code. Here, the scale factor is a measure of the display resolution and hence font size (in pixels) should indeed scale with the "scaling" factor.
    pngcairo, pdfcairo, and epscairo terminals on the otherhand always assume 72dpi and the font size should not scale with the Windows text "scaling" factor.

    Looking at the code, there's no difference in treatment of font size in gnuplot's cairo/pango code for different output formats. So this might be considered a bug in cairo/pango. We now explicitly set the font resolution to 96 dpi for all cairo
    terminals, but for wxt we set it to the screen resolution instead.

     
  • Ethan Merritt

    Ethan Merritt - 2020-12-23

    After the fix I am getting the following warning during compilation:

    wxterminal/gp_cairo.c: In function gp_cairo_set_resolution:
    wxterminal/gp_cairo.c:818:38: warning: passing argument 1 of pango_cairo_font_map_set_resolution from incompatible pointer type [-Wincompatible-pointer-types]
      pango_cairo_font_map_set_resolution(pango_cairo_font_map_get_default(), dpi);
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from wxterminal/gp_cairo.c:73:
    /usr/include/pango-1.0/pango/pangocairo.h:95:71: note: expected PangoCairoFontMap * {aka struct _PangoCairoFontMap *} but argument is of type PangoFontMap * {aka struct _PangoFontMap *}
     void          pango_cairo_font_map_set_resolution (PangoCairoFontMap *fontmap,
                                                        ~~~~~~~~~~~~~~~~~~~^~~~~~~
    

    I have not noticed any problems with using the wxt terminal, however, despite the warning.

     
    • Bastian Märkisch

      Sorry about this oversight, this was cleary missing a type conversion. Fixed.

       
  • Bastian Märkisch

    • status: pending-fixed --> open
     
  • Bastian Märkisch

    Opening this tracker again. After updating from pango 1.46.1 to 1.48.0, and cairo from 1.16.0 to 1.17.4, it seems the correction is now applied twice.
    From the respective changelogs, I cannot tell where this was changed.

     
  • Aaron Zick

    Aaron Zick - 2021-05-30

    As of gnuplot 5.4.1, this is still a bug. It affects terminals pngcairo and pdfcairo, at the very least. It's a very serious problem. If you give a gnuplot script to a Windows 10 user, there's no telling how ugly his plots will turn out, because they'll be completely dependent on the Scale and Layout setting he has chosen for his display. Plots that are written to ,png or .pdf files should NOT depend on any display settings!

     
    • Ethan Merritt

      Ethan Merritt - 2021-05-30

      The change made by Bastian came just after the release of 5.4.1. It will be in the 5.4.2 release planned for June. It is unclear to me from the comment stream above whether this does or does not resolve the issue. Note that using gnuplot 5.4 on Windows 10 currently has other issues as well, so a Windows-specific followup to the 5.4.2 release may be needed.

       
    • Ethan Merritt

      Ethan Merritt - 2021-05-31

      Also I don't understand why the change/fix was to set 96 dpi rather than 72 dpi. Does this mean that a cairopdf or cairopng plot file produced under Windows will have a different font size than the file produced by the same gnuplot commands executed under linux?

      Edit: Never mind. I see that the pango/cairo default is documented as 96 dpi (but then why do we have to set it at all?)

       

      Last edit: Ethan Merritt 2021-05-31
      • Bastian Märkisch

        We shouldn't have to. But some versions of the library seem to somehow scale fonts with the "Windows scaling" factor, which essentially is the overall DPI setting. So we expicitely set it on Windows.

         
  • Bastian Märkisch

    • labels: Windows, cairo --> Windows, cairo, pdfcairo, pngcairo, wxt
    • status: open --> pending-fixed
     
  • Bastian Märkisch

    Further testing with 5.4.2 gives consistent results for png- and pdfcairo, as well as wxt for different "scaling factors". Also, the font size is now consitent with results on Ubuntu 20.04. Note that the font size is smaller than what version 5.4.1 would produce at 100%, though. So for some, this might actually break existing scripts and font size or the overall "fontscale" have to be adjusted.

     
  • Ethan Merritt

    Ethan Merritt - 2021-12-25
    • Status: pending-fixed --> closed-fixed
     

Log in to post a comment.