#!/usr/bin/perl -w

use strict;
use Gimp;

my $font = '/usr/local/share/ttf/britanic.ttf';
my $text = 'gimp.org';

# Render text via gimp-freetype
Gimp::on_net {
    my $img = new Gimp::Image(400, 40, RGB);
    my $bg = $img->layer_new(400, 40, RGB_IMAGE, "bg-$text", 100, NORMAL_MODE);

    $bg->add_layer(1);
    Palette->set_foreground([0, 0, 0]);
    Palette->set_background([255, 255, 255]);
    $bg->edit_fill(BG_IMAGE_FILL);

    new Gimp::Display($img);

    $bg->freetype (
        $font,      # font file
        36.0,       # size
        PIXELS,     # unit
        1, 0, 0, 1, # transform matrix
        1,          # kerning
        1,          # hinting
        1,          # antialiasing
        0,          # bezier outline
        0,          # spacing
        $text       # text
    );

    Display->displays_flush();
};

# Make sure nobody tried to install this as a plug-in
Gimp::on_lib { print STDERR "$0: Don't run this from inside The GIMP!\n"; };

exit main;

# EOF

