root-project / root

The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
https://root.cern
Other
2.63k stars 1.25k forks source link

Improve loading system fonts #16229

Open stephanlachnit opened 4 weeks ago

stephanlachnit commented 4 weeks ago

Feature description

Currently, ROOT loads fonts via the Root.TTFontPath. This makes a lot of sense from a ROOT maintainer perspective (simply ship all used fonts), but is a roadblock for a distribution maintainer (embedded files are usually not wished if not otherwise possible).

Thus, it would be nice if ROOT would additionally support fontconfig, which is the default way to find fonts on Linux. In particular, the font interface should first look into Root.TTFontPath and then fallback to fontconfig. This means that the font-finding interface needs two parameters: the font file name and a fontconfig name as fallback.

The current font interface is a bit all over the place. There is at least graf2d/graf/src/TTF.cxx, graf3d/gl/src/TGLFontManager.cxx and graf3d/gl/src/TGLText.cxx that handle font names, probably more.

Fedora uses this patch from @ellert to get rid of the non-free MS fonts (see also https://github.com/root-project/root/issues/8357), which is a good start but the patch is not really feasible upstream due to Windows/OSX support.

/cc @Axel-Naumann @dpiparo

Alternatives considered

No response

Additional context

No response

couet commented 4 weeks ago

Thank you for your input. As you mentioned, fontconfig is a Linux utility, but we also need to support Windows and macOS. Additionally, we aim to achieve the best possible mapping to PostScript and PDF fonts (without loading fonts in PostScript). The font set was carefully chosen to ensure optimal mapping across all these backends. You can also include TPDF and TPostScript in the list of files related to fonts. Recently, due to licensing issues with Helvetica, we made some changes to the font files used to render ROOT fonts. Now, ROOT is shifting towards a new graphics system called "Web Graphics," where the latest graphics developments are happening. I believe this request should be considered for implementation in this new context, if feasible.