Re: Default font question

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

 



Am Mi, den 19.05.2004 um 14:45 Uhr +0400 schrieb Andrew E. Makeev:
> Hi
> 
> Could someone explain, please, how should I to determine default font 
> name for widget where it's applicable (label, textview, etc)?
> I have used these methods:
> 
> 1. Using GtkStyle: Gtk::Label ().get_style ()->get_font ().to_string () 
> - returned "Sans 10"
> 2. Using GtkRcStyle: Gtk::Label ().get_modifier_style ()->get_font () - 
> returned Pango::FontDescription with gobj() == 0 (no font specified)

1. and 2. are essentially identical.  "Sans 10" is returned if
Pango::FontDescription doesn't specify a valid font.  The problem is
that you can't just instantiate a dummy Gtk::Label() and expect the
desktop environment's default font to be assigned to it.  IIRC the
widget styles are set up recursively as soon as the toplevel window is
realized.

> It's fine for Linux, but wrong on Win32 system, because it uses theme 
> font = "Thahoma 8".
> Is there a right way to get theme default font name? (An example will be 
> much better than lotsa theory :) )

The best way to access the default font, and also to keep track of it in
case the user changes that setting while your app is running, would be
something like this:

MyWindow::on_style_changed(const Glib::RefPtr<Gtk::Style>& previous_style)
{
  Gtk::Window::on_style_changed(previous_style);
  app_font_ = get_pango_context()->get_font_description();
}

This assumes that MyWindow is your toplevel window class derived from
Gtk::Window, and that you didn't assign a custom font to it.

Cheers,
--Daniel


_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux