Fw: Rendering text with an outline



Hi,

I am not sure who the maintainer of pangomm is but you will see the
suggestion that pango_cairo_show_layout() should be wrapped (presumably
as a method of Pango::Layout, by analogy with
pango_cairo_show_layout_line() being a member of Pango::LayoutLine).

Chris

------------------------------------------
Begin forwarded message:

Date: Sat, 7 Mar 2009 18:44:04 +0200
From: Dov Grobgeld <dov grobgeld gmail com>
To: Chris Vine <chris cvine freeserve co uk>
Cc: Christian Schaubschlaeger <cs gup uni-linz ac at>,
gtk-list gnome org Subject: Re: Rendering text with an outline

Note that it is not completely trivial to use pango_show_layout_line
instead of pango_show_layout as they have different anchor points.
pango_show_layout draws with the current point at the upper logical
extent of the layout, and pango_show_layout_line draws with respect to
the baseline of the text. See:

http://live.gnome.org/PangoLayoutLineBbox

Thus it does not make sense to create a binding for just one of them.

Regards,
Dov

2009/3/7 Chris Vine <chris cvine freeserve co uk>

> On Fri, 06 Mar 2009 12:14:53 +0100
> Christian Schaubschlaeger <cs gup uni-linz ac at> wrote:
> > Dov Grobgeld schrieb:
> > > I cleaned up my example a bit and put it in GnomeLive. See:
> > >
> > > http://live.gnome.org/OutlineLabel
> >
> > Thanks for the example!
> > I'm just trying to port it to gtkmm. Unfortunately I
> > cannot find the corresponding C++ construct for the
> > "Pango.cairo_show_layout()" call in Dov's Vala code.
> > Would that be a pangocairo function? I could not find
> > C++ bindings for the pangocairo lib. Are there any?
> > However, I'm not sure if the code snippet below is
> > correct at all, I'm (unfortunately) new to Pango and
> > Cairo...
> >
> > Thanks and best regards
> > Christian
> >
> > bool
> > OutlineLabel::on_expose(GdkEventExpose *event)
> > {
> >     //Gdk::cairo_create(this->window);
> >     Cairo::RefPtr<Cairo::ImageSurface> surface;
> >     Cairo::RefPtr<Cairo::Context> cr;
> >     Glib::RefPtr<Pango::Layout> layout;
> >     int width,height;
> >
> >     layout = this->get_layout();
> >     width = -1; height = -1;
> >     layout->get_size(width,height);
> >
> >     surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,
> > width, height); cr = Cairo::Context::create(surface);
> >
> cr->move_to((this->get_allocation().get_width()-width/Pango::SCALE)/2,0);
> >     cr->set_sorce_rgba(1,0,0,1);
> >
> >     // in VALA: Pango.cairo_show_layout(cr,layout);
> >     // in C++?
> >     ...
> >
> > }
>
> pango_cairo_show_layout() does not appear to be wrapped, but
> pango_cairo_show_layout_line() is (as
> Pango::LayoutLine::show_in_cairo_context()), so I suggest you use that
> with Pango::Layout::get_line() and/or Pango::Layout::get_lines().
>
> Chris
>
Note that it is not completely trivial to use pango_show_layout_line instead of pango_show_layout as they have different anchor points. pango_show_layout draws with the current point at the upper logical extent of the layout, and pango_show_layout_line draws with respect to the baseline of the text. See:

http://live.gnome.org/PangoLayoutLineBbox

Thus it does not make sense to create a binding for just one of them.

Regards,
Dov

2009/3/7 Chris Vine <chris cvine freeserve co uk>
On Fri, 06 Mar 2009 12:14:53 +0100
Christian Schaubschlaeger <cs gup uni-linz ac at> wrote:
> Dov Grobgeld schrieb:
> > I cleaned up my example a bit and put it in GnomeLive. See:
> >
> > http://live.gnome.org/OutlineLabel
>
> Thanks for the example!
> I'm just trying to port it to gtkmm. Unfortunately I
> cannot find the corresponding C++ construct for the
> "Pango.cairo_show_layout()" call in Dov's Vala code.
> Would that be a pangocairo function? I could not find
> C++ bindings for the pangocairo lib. Are there any?
> However, I'm not sure if the code snippet below is
> correct at all, I'm (unfortunately) new to Pango and
> Cairo...
>
> Thanks and best regards
> Christian
>
> bool
> OutlineLabel::on_expose(GdkEventExpose *event)
> {
>     //Gdk::cairo_create(this->window);
>     Cairo::RefPtr<Cairo::ImageSurface> surface;
>     Cairo::RefPtr<Cairo::Context> cr;
>     Glib::RefPtr<Pango::Layout> layout;
>     int width,height;
>
>     layout = this->get_layout();
>     width = -1; height = -1;
>     layout->get_size(width,height);
>
>     surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,
> width, height); cr = Cairo::Context::create(surface);
>     cr->move_to((this->get_allocation().get_width()-width/Pango::SCALE)/2,0);
>     cr->set_sorce_rgba(1,0,0,1);
>
>     // in VALA: Pango.cairo_show_layout(cr,layout);
>     // in C++?
>     ...
>
> }

pango_cairo_show_layout() does not appear to be wrapped, but
pango_cairo_show_layout_line() is (as
Pango::LayoutLine::show_in_cairo_context()), so I suggest you use that
with Pango::Layout::get_line() and/or Pango::Layout::get_lines().

Chris



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