Re: Non-ascii characters break Cairo's show_text



Torsten Schoenfeld wrote:
The answer is usually to use pango for any non-trivial text
rendering.

Thanks, the rendering is quite trivial also with pango and I don't notice any slowdown in rendering, here's a snippet for somebody needing a code snippet (I found the documentation a bit confusing):

# $cr is cairo context, @pixel is where to put text, $wc, $hc, and $dw are adjustments
my $layout = Gtk2::Pango::Cairo::create_layout($cr);
$layout->set_text($text);
my($width, $height) = $layout->get_size;
$width /= Gtk2::Pango->scale;
$height /= Gtk2::Pango->scale;
$cr->move_to($pixel[0]+$wc*$width+$dw, $pixel[1]+$hc*$height);
Gtk2::Pango::Cairo::show_layout($cr, $layout);

The remaining problem is that I was not able to easily get the $layout->set_font_description working to set the font from I get from the FontSelectionDialog. BTW, I find parsing what it returns in get_font_name difficult.

Cheers,

Ari

--
Prof. Ari Jolma
Geoinformaatio- ja paikannustekniikka / Geoinformation and positioning
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




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