On 2018-05-02 12:44, macpo...@parvis.nl wrote:
Macports installs fonts in /opt/local/share/fonts.
This directory is seen only by fontconfig (defined in /opt/local/etc/fonts/fonts.conf).

Most software uses cairo for advanced font handling and pango for the heavy-lifting in cairo. This is called pangocairo. rrdtool has '#include <pangocairo.h>'.

Pango has a simple tool to show font examples:
pango-view --backend=<backend> --text '   iiiiwwww  ' --font 'DejaVuSansMono 36' # execute in XQuartz

I think this should be
  --font 'DejaVu Sans Mono 36'
At least it only works for me with spaces when I manually install the font to /Library/Fonts/DejaVuSansMono.ttf.

Note that backend is for pango, not for cairo.
With backend 'xft' or 'ft2' DejaVu shows fine.
With backend 'cairo' the replacement is done ('cairo' is the default backend for pango, see pangocairo).

The problem lies in cairo. If 'quartz' is enabled, 'fontconfig' is not used.
The Portfile for cairo explicitely enables 'quartz' and 'x11'.
With 'quartz' disabled everything works as expected.

I cannot oversee the consequences of disabling 'quartz' for cairo.

The native macOS font renderer searches for fonts only in paths such as ~/Library/Fonts, /Library/Fonts, and /System/Library/Fonts as documented in [1]. There does not seem to be a way to extend that.

We could install our fonts to a path such as /Library/Fonts/MacPorts/ to make them available to native applications by default. However, this would be a long-term solution as that requires changes in base for a ${fonts_dir} to be handled just like ${applications_dir}.

On the pango mailing list, Behdad Esfahbod offered the solution to set environment variable 'env var PANGOCAIRO_BACKEND=fc' and that works fine.

While I agree this is a problem that should be solved for all ports, one workaround for rrdtool would be to use a simple shell script wrapper that exports this environment variable before executing the real binary.

However, that is only necessary if rrdtool can only work correctly with "DejaVu Sans Mono". Would it be acceptable to use a different font that is always available for the time being? Even a generic 'monospace' should give similar results.

Rainer

Reply via email to