1
votes

I am developing a dialog for my application using Ruby Gtk and have a requirement of displaying the text on the dialog in the Open Sans font. I have used Pango markup below to achieve this and seems to work as expected on my system.

<span font_family=\"Open Sans\" foreground=\"black\" size=\"x-small\" weight=\"bold\">#{value}</span>

To make it work though, I also had to manually install the Open Sans font onto my system. Without doing so, I was seeing the following warning in the application log file.

Pango-WARNING **:couldn't load font "Open Sans Bold Not-Rotated 10", falling back to "Sans Bold Not-Rotated 10", expect ugly output.

I know it is possible to specify multiple fonts in case of HTML in descending order of preference as a fallback in case a certain font doesn't exist and such a logic would be acceptable in my case. But I can't seem to find an example on the internet. Is it even possible to specify multiple fonts with Pango markup? If so, how? If not, is there any other way around this warning other than installing the font?

1
Gtk is not HTML. You need to check what all system fonts are available, if what you want is their use it or else choose another. You can use Electron if prettiness is top priority.arjun

1 Answers

0
votes

AFAIK there is no way to specify multiple fonts. You can obtain a list of all available fonts (that's how it's done in C) and then iterate over that list, finding the one that fits best.