Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

gdynfont.pl - A Gimp plug_in

by simonflk (Pilgrim)
on May 13, 2002 at 21:17 UTC ( #166298=sourcecode: print w/ replies, xml ) Need Help??

Category: Utility Scripts
Author/Contact Info Simon Flack simonflk
http://www.simonflack.com
Description: This plugin will display information about a GDynText layer in the Gimp.

Background
I needed to find out the name of the font that I used in a .XCF a few months ago. I didn't have the font installed anymore, so GDynText selected the first font in the list. It may be that I have overlooked a simpler way of working out the font, nevertheless, this was a nice excursion into Gimp-Perl. Unless you are in a similar situation (no longer have a font, or someone gives you a Gimp file without associated fonts), this will be pretty useless because it doesn't display anything that you can't get from GDynText itself.

Installation
Copy this script into your ~/.gimp-1.2/plug-ins folder and make it executable.

Usage:
Select a GDynText layer and then select GDynFontInfo from the <Image>/Script-fu/Utils menu
#!/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;

}

Comment on gdynfont.pl - A Gimp plug_in
Download Code

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://166298]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2014-12-29 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (184 votes), past polls