Re: How can I change the font of a text field using non-deprecated way?



On Sat, Sep 22, 2018 at 3:11 PM Радомир Хаџић via gtk-app-devel-list
<gtk-app-devel-list gnome org> wrote:

I'm trying to make a small application in C using GTK+3 (the latest
stable). The application is going to have a text field implemented using
GtkTextView where a user can write text. I also font a user to be able to
change font, so I've added a font chooser using GtkFontChooserDialog.

The problem is that I don't know how to actually set the font of a text
field to the one that a user chose using font chooser. Well, at least not
using an up-to-date method. I know I can use gtk_widget_override_font(),
and though it works perfectly, I'd rather not use it since it's deprecated
function so it's not meant to be used anymore.

The functionality you are describing is present in pretty much every
GTK+3-based text editor, so look at the source of any one of them.

Gedit (as of 3.18.3 as packaged in Ubuntu 16.04) uses
gtk_widget_override_font, and so does Mousepad (as of 0.4.0), and
what’s good for the stock text editors of GNOME and Xfce, is probably
good for you, too.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]