Re: Render PNG with Pango
- From: muppet <scott asofyet org>
- To: Steven Mullins <sbmullins ntelos net>
- Cc: gtk-perl-list gnome org
- Subject: Re: Render PNG with Pango
- Date: Sun, 11 May 2008 00:00:05 -0400
On May 10, 2008, at 5:10 PM, Steven Mullins wrote:
I need to render some utf-8 text with pango to a PNG. I can do
this, but not
without flashing the image on the screen for an instant to draw the
pixmap.
does anyone know how to do this without displaying the image to the
screen?
A short example would be great.
How's this? Size is hardcoded, that's for you to figure out. The
font and text come straight from your example code.
#!/usr/bin/perl -w
use strict;
use Gtk2;
use Cairo;
my $surface = Cairo::ImageSurface->create ('argb32', 300, 200);
my $cr = Cairo::Context->create ($surface);
$cr->rectangle (0, 0, 300, 300);
$cr->set_source_rgb (1, 1, 1);
$cr->fill;
my $pango_layout = Gtk2::Pango::Cairo::create_layout ($cr);
my $font_desc = Gtk2::Pango::FontDescription->from_string("Ezra SIL
26");
$pango_layout->set_font_description($font_desc);
$pango_layout->set_markup ("Tango Pango
\n
י
;ִ
;שְׂרָאֵל
אֱלֹהִים");
$cr->set_source_rgb (0, 0, 0);
Gtk2::Pango::Cairo::show_layout ($cr, $pango_layout);
$cr->show_page ();
$surface->write_to_png ('output.png');
__END__
--
So this new album took us quite a while, to get it together, to find a
title and things like that - and we were travelling quite a bit - we
made a few sort of gestures in the East, and a few gestures in the
West, and then we got thrown out because of our gestures - this is
something that we decided was an apt title for a thing that's called
'The Song Remains The Same'.
-- Robert Plant, rambling to introduce a song
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]