Menu

#2739 Font style defaults with PDFCairo

None
closed-not-a-bug
nobody
None
2024-12-21
2024-10-09
Anonymous
No

Gnuplot version: 6.0 patchlevel 1 (Homebrew)
Operating system: MacOS 15.0.1

Using the pdfcairo terminal, with DejaVu fonts installed, the "Condensed" family is selected as the default, even when not requested:
set term pdfcairo size 2.5,2 font "DejaVu Sans,8"

I checked fontconfig on my system, which returns the correct regular-style font, "Book", as expected:

~: fc-match "DejaVu Sans"
DejaVuSans.ttf: "DejaVu Sans" "Book"

The only solution I have found is to uninstall the "Condensed" style. The attached images show example plots with the same set term line above, before and after uninstalling the "Condensed" style.

2 Attachments

Discussion

  • Ethan Merritt

    Ethan Merritt - 2024-10-17

    I can only provide a partial answer, and only for gnuplot builds that use the cairo library
    s PangoCairo backend for font resolution via fontconfig. That is true for linux, but I gather it is more complicated on MacOS.

    linux (PangoCairo backend using fontconfig)

    According to the pango library header file, "Book" is one possible value of the PANGO_WEIGHT enum. On the other hand, "Condensed" is a possible value of the PANGO_STRETCH enum.

    Gnuplot explicitly sets the weight property to either "Normal" or "Bold" (other values are possible but gnuplot doesn't use them). The pango library is then supposed to pick whichever available weight variant is closest to the requested value.

    Gnuplot doesn't explicitly set the stretch property at all, so you get whatever the pango library thinks is the default stretch value. I don't know if that default can be changed, but if so it would be via some more general font management mechanism outside of gnuplot. Probably you can do it by editing your system or personal fonts.conf file.

    MacOS (a mess)

    MacOS allows multiple font-handling subsystems. I believe that the MacOS gnuplot builds do use PangoCairo (but I'm not 100% sure), but even so there are further configuration choices that can are affected by the environmental variable PANGO_CAIRO_BACKEND.

    • PANGOCAIRO_BACKEND=fc
      PangoCairo uses PangoFcFontMap to discover fonts on the system

    • PANGOCAIRO_BACKEND=coretext
      PangoCairo uses PangoCoreTextFontMap to discover fonts

    Your fc-match command queries fontconfig, but it is at least possible that gnuplot + cairo + pango ends up using instead CoreText font handling rather than fontconfig. You could try setting that environmental variable before running gnuplot and see if anything changes. I suggest asking on a HomeBrew forum.

     
  • oruxl

    oruxl - 2024-10-17

    Wow, you are spot-on! With the condensed style installed, PANGOCAIRO_BACKEND=fc corrects the issue, and I can also specify ":Condensed" in the set term line to switch to the condensed style as expected.

    I'm not sure if this is a bug, but maybe a warning could be added to point out the potentially unexpected behavior on MacOS builds?

     
    • Ethan Merritt

      Ethan Merritt - 2024-10-17

      Glad to hear it's now working for you.

      The problem with trying to document these things is that font handling in general, and in particular via pango and fontconfig, has been in a state of turbulent churn for the past several years. They keep changing things underneath, and programs that sit on top of that like gnuplot are affected in strange ways. For example certain fonts that used to work fine no longer work correctly, or work only with certain library versions or with certain display settings. There are a a bunch of open issues on the gnuplot bug tracker that come down to problems with font handling; for most of them the only possible answer is 'try to upgrade or downgrade your library versions, or change the fonts you are using'. But yes, maybe it would help to tell people they should look at the cairo/pango project documentation that matches whatever version they have installed.

       
  • Ethan Merritt

    Ethan Merritt - 2024-11-08
    • status: open --> open-not-a-bug
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2024-12-21
    • status: open-not-a-bug --> closed-not-a-bug
     

Log in to post a comment.