2

I use gtk-rs to implement a little of UI for an AppIndicator application. I would like to make certain menu items in my appindicator menu bold, but I can't figure out how to go about it.

The menu item is initialized like so:

let foobar = gtk::MenuItem::with_label("Foobar");

What is the magic incantation to make that label bold?

Boris Terzic
  • 10,858
  • 8
  • 45
  • 59
  • From a rendering perspective, bold or italic text might as well be a completely different font. You likely need to switch out the font being used with a separate bold version. For example when you download a font from https://fonts.google.com/, the zip folder will include a separate `.ttf` file for each style/weight of a given font. – Locke Mar 24 '22 at 15:13
  • Poking through the `gtk` docs, it sounds like `weight` might effect how strong/bold a font is. You may want to look for a `set_weight` function. – Locke Mar 24 '22 at 15:16
  • @Locke that's not how a GUI Toolkit should work. I don't want to use a different font than the system itself. The menu should integrate nicely with all the others on the system. I just noticed that nm-applet for example is an appindicator and has differently styled menu entries. – Boris Terzic Mar 24 '22 at 16:47
  • Have you tried the solution from https://stackoverflow.com/questions/7189338/how-to-display-rich-text-in-a-gtk-menuitem-label, using HTML bold markers ? – Magix Mar 24 '22 at 17:06
  • 1
    @Magix I tried to but couldn't get it to work. Since this is Rust, it wasn't that obvious to me to get the child and set markup. I came up with this, it compiled, but didn't do anything: `let mi = gtk::MenuItem::with_label("Quit"); let label: Widget = mi.get_child().unwrap(); label.downcast:: – Boris Terzic Mar 24 '22 at 17:21

0 Answers0