FreeType integration for Cairo



Aloha,

I just committed a patch to HEAD of CVS of Cairo which lets you create
Cairo font faces from FreeType font faces:

  use Cairo;
  use Font::FreeType;

  my $file = '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf';
  my $ft_face = Font::FreeType->new->face ($file);
  my $cr_face = Cairo::FtFontFace->create ($ft_face);

  my $surface = Cairo::ImageSurface->create ('argb32', 200, 40);

  my $cr = Cairo::Context->create ($surface);
  $cr->set_font_face ($cr_face);
  $cr->set_font_size (23);
  $cr->move_to (20, 25);
  $cr->show_text ('Hello, world!');
  $cr->show_page;

  $surface->write_to_png ('test.png');

You'll need a cairo compiled with FreeType support to get this.  And you
need the Font::FreeType module to actually use it.

Comments are welcome.

-- 
Bye,
-Torsten




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