Supposing you already have a Window with an Entry, named txtSource, this is how you change the Font.
First, include Pango in imports.
using Pango;
Second, use the FontDescription class and instanciate one.
FontDescription fontDesc = new FontDescription();
Third, set the Family property of FontDescription object to any font family you want (ex, "Arial", "Tahoma", "Courier).
fontDesc.Family = "Courier";
Lastly, set the FontDescription object to Entry using ModifyFont method.
txtSource.ModifyFont(fontDesc);
The whole code should look something like this:
using System; using Gtk; using Pango; public partial class MainWindow : Gtk.Window { public MainWindow () :base(Gtk.WindowType.Toplevel) { Build(); FontDescription fontDesc = new FontDescription(); fontDesc.Family = "Courier"; txtSource.ModifyFont(fontDesc); } }
No comments:
Post a Comment