Re: what font is actually used?



Sorry about the delay.

On 03/10/11 17:36, D. R. Evans wrote:
Ian Martin said the following at 10/02/2011 06:52 PM :

Looking at the docs at
http://developer.gnome.org/gtkmm/unstable/classGtk_1_1Label.html , I'd
be using
void 	set_attributes
<http://developer.gnome.org/gtkmm/unstable/classGtk_1_1Label.html#a79b1642f8314e17babcc2808e74315b1>
(Pango::AttrList
<http://library.gnome.org/devel/pangomm/unstable/classPango_1_1AttrList.html>&
attrs)
	Sets a Pango::AttrList
<http://library.gnome.org/devel/pangomm/unstable/classPango_1_1AttrList.html>;
the attributes in the list are applied to the label text.
OK, I'll try to wade through that tomorrow. It looks horribly complicated
for such a simple thing as changing a font to something other than the default.

Modified  out of the button example in the manual:

#include "buttons.hpp"
#include <iostream>

Buttons::Buttons()
{
    Gtk::Label* lab = Gtk::manage( new Gtk::Label());
    m_button.add(*lab);

    set_title(" Button ");
    set_border_width(10);
lab->set_markup("<span foreground='blue' size='x-large'>Markup language</span> is <i>a world of its own</i>!");
    lab->set_use_markup();
    m_button.signal_clicked().connect( sigc::mem_fun(*this,
&Buttons::on_button_clicked) );

    Glib::ustring lb = lab->get_text();
    add(m_button);

    show_all_children();
}

Buttons::~Buttons()
{
}

void Buttons::on_button_clicked()
{
  std::cout << "The Button was clicked." << std::endl;
}

Can you please tell me what was wrong with using override_font()? The
documentation for that font explicitly says: "Sets the font to use for a
widget", which is exactly what I want to do.

So why is using override_font() to change the font incorrect?

Inherently nothing, if it works :-)
However, when you want to change the weight/ colour/ whatever else, you've backed yourself into a corner. The pango markup language isn't supposed to be complicated, just powerful.
get_attributes () const
	Gets the attribute list that was set on the label using
set_attributes()
That seems to say that it will simply return the same information as was
passed using set_attributes(). Is that not so?
Yes, but then so it should. If you change the attributes, they're changed to something; if it's not a default, you probably want to know about it. The point is text has a _lot_ of attributes; this function won't tell you about your default settings.
(The documentation should be a lot clearer if my interpretation of the text
is incorrect. The documentation in that case should say something simply to
the effect of "returns the attributes", without any reference to the
set_attributes() function. If a prior set_attributes() function isn't
important, it shouldn't be mentioned.)

   Doc




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