Gtk Change Font and font color for an application

前端 未结 2 977
北恋
北恋 2021-01-22 07:20

I am having one Gtk+ and C application in which i want to set the font to some XYZ font type and font color to blue, for all the labels and text in the application how can i do

相关标签:
2条回答
  • 2021-01-22 07:51

    It is generally considered bad form to do that; apps should respect the user's theme. That said, you can deploy a resource file with the settings you want to override in your application, and then use gtk_rc_parse() to load the file at runtime.

    Check out GTK+ Resource Files documentation for details.

    0 讨论(0)
  • 2021-01-22 07:55

    I also wanted to change the size of the font (because in the windows I don't see any common way how to modify general GTKMM's font size, and user wants bigger fonts because he has small screen).

    This works, when called before displaying window:

    style = formatString( "style \"my-style\" { font_name = \"Mono %i\" } class \"*\" style \"my-style\"", fontSize);
    gtk_rc_parse_string( style );
    

    This is a way to 'create application setting' and apply it on the fly. By the way, class "*" means that all items will have this style applied.

    0 讨论(0)
提交回复
热议问题