Gtk-rs 3. Is it possible to load ttf files with Pango?

Hi. I’m building a cross-platforms application (Linux, MacOs, Windows) with Gtk rs 3. But I need to use a ttf font downloaded on the Web.

So I’ve searched for a tutorial about ttf integration with Pango, but I did not found how to do that, or if that’s possible.

So is there a tutorial for that ?

Hello! Pango2 is going to have built-in support for custom fonts, but you can achieve the same with Pango1, provided you do a bit of work. Basically, we’re going to augment the system font collection with the custom font. Of course that’s only for our process, other processes will not see the custom font.

By default, for font enumeration Pango uses Fontconfig on unix systems, GDI and DirectWrite on Windows and CoreText on macOS. Note that you also have the option of using Fontconfig for all platforms, but Fontconfig had to be enabled when building Pango (this is done e.g in MSYS2). This can be done by setting the environment variable PANGOCAIRO_BACKEND=fc. The environment variable should be set at the start of your main function.

Here are guides for adding a custom font to the system collection:

Hi ! Thank you very much for this explanation :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.