#!/usr/bin/perl -w
#################################################################
# gdynfont.pl
#
# Gimp plug_in to display font details for a GDynText layer
# Author: Simon Flack
# Date: May 13 2002
#################################################################
use strict;
use Gimp qw(:auto);
use Gimp::Fu;
use Gtk '-init';
register ("gdyntext_font_info",
"Find out the font used in a GDynText layer",
"Display font details for a GDynText Layer",
'Simon Flack <mail@no-spam.simonflack.com>',
"Simon Flack",
"13 May 2002",
"<Image>/Script-Fu/Utils/GDynFontInfo", "*",
[],
\&info_from_gdyntext_layer);
exit main;
sub info_from_gdyntext_layer
{
my ($image, $drawable) = @_;
my $output;
my $parasite = gimp_drawable_parasite_list($drawable);
unless ( $parasite =~ /plug_in_gdyntext\/data/ )
{
# It's not a GDynText layer
$output = "The selected layer is not a Dynamic Text Layer";
} else {
# Get the parasite details for the GDynText layer and parse it
my $text_parasite =
gimp_drawable_parasite_find($drawable, "plug_in_gdyntext/data")-
+>[2];
my ($text, $antialias, $alignment, $rotation,
$line_spacing, $color, $l_alignment, $font)
= $text_parasite =~ /{([^\}]+)}/g;
my $antialias_bool = $antialias ? "yes" : "no";
my @layer_alignment = qw(none
bottom-left bottom-center bottom-right
middle-left center middle-right
top-left top-center top-right);
my @text_alignment = qw(left center right );
$output = <<FONTINFOOUTPUT;
text: $text
antialias: $antialias_bool
anlignment: $text_alignment[$alignment]
rotation: $rotation
line_spacing: $line_spacing
color: #$color
layer alignment: $layer_alignment[$l_alignment]
font: $font
FONTINFOOUTPUT
}
# Display a Gtk::Window with the results
my $window = new Gtk::Window("toplevel");
$window->set_title("GDynFont: Font Information");
$window->border_width(5);
my $label = new Gtk::Label($output);
$label->set_justify("left");
$window->add($label);
$label->show;
$window->show;
main Gtk;
}
|