Files
gimp/plug-ins/perl/examples/fit-text
Michael Natterer d81b47ce70 removed GimpFillType.
2001-06-29  Michael Natterer  <mitch@gimp.org>

	* app/appenums.h: removed GimpFillType.

	* app/gimprc.c: parse the session-info's new "aux-info" field.

	* app/global_edit.[ch]: removed the old "Paste Named" dialog and
	prefixed all functions with "gimp_".

	* app/core/core-types.h: added GimpFillType.

	* app/core/gimpbrush.[ch]: new signal "spacing_changed".

	* app/gui/Makefile.am
	* app/gui/tools-commands.[ch]: one more file cut out of commands.[ch].

	* app/gui/commands.[ch]: removed the tools stuff here.

	* app/gui/brush-select.[ch]
	* app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView
	(see below).

	* app/gui/dialogs-commands.[ch]
	* app/gui/menus.[ch]:

	- Made it 64bit safe again by passing the dialog factory's
	  identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT().
	- Added a "gchar *quark_string" field to GimpItemFactoryEntry
	  which gets transformed into a GQuark by menus_create_item().
	- Added SEPARATOR() and BRANCH() macros which make the *_entries[]
	  arrays more readable.
	- Added a menu item to show/hide GimpImageDock's image menu.
	- Removed file_last_opened_cmd_callback().

	* app/gui/edit-commands.c: the global_edit functions are "gimp_"
	prefixed now.

	* app/gui/file-commands.[ch]: added file_last_opened_cmd_callback()
	here.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h
	* app/widgets/gimpbrushfactoryview.[ch]: new widget: a
	GimpDataFactory subclass with a "spacing" scale.

	* app/widgets/gimpcontainereditor.[ch]:

	- Connect to the GimpContainerView's "select_item",
	  "activate_item" and "context_item" signals here once instead of
	  in each subclass and dispatch them via new virtual functions.
	- Added a convenience function which makes DND to the buttons much
	  less painful for subclasses.

	* app/widgets/gimpbufferview.c
	* app/widgets/gimpdatafactoryview.[ch]: changed accordingly.

	* app/widgets/gimpdialogfactory.[ch]:

	- Added gimp_dialog_factory_dialog_raise() which can raise
	  toplevel dialogs _and_ dockables (and creates them if they are
	  not open yet).
	- Keep track of all created dialogs (not only toplevels).
	- Added an "aux_info" field to GimpSessionInfo which is a GList of
	  gchar* and is saved in sessionrc.
	- Remember if GimpImageDock's image menu is visible by using an
	  aux_info string.
	- The code did not become nicer with all those new constraints. I
	  have to add comments before I forget how it works.

	* app/widgets/gimpdockbook.c: set the state of the "Show Image Menu"
	menu item before popping up the item factory.

	* app/widgets/gimpimagedock.[ch]: added
	gimp_image_dock_set_show_image_meu().

	* plug-ins/gdyntext/gdyntext.c
	* plug-ins/perl/examples/fit-text
	* plug-ins/perl/examples/terral_text
	* plug-ins/perl/examples/tex-to-float: register all text rendering
	plug-ins under <Image>/Filters/Text

	* app/pdb/brush_select_cmds.c
	* app/pdb/drawable_cmds.c
	* app/pdb/edit_cmds.c
	* tools/pdbgen/pdb/brush_select.pdb
	* tools/pdbgen/pdb/edit.pdb
	* tools/pdbgen/enums.pl
	* po/POTFILES.in: changed according to all the stuff above.
2001-06-29 19:25:03 +00:00

114 lines
3.9 KiB
Perl
Executable File

#!/usr/app/bin/perl
eval 'exec /usr/app/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
# <sjburges@gimp.org>
# This is adrian and xachs idea - take a rectangluar selection, and select
# font type and string. Then fill it with whatever size is needed.
# This uses highly non-scientific "for my test image these were ok"
# approximations - I didn't chart anything or calcualte tradeoffs. Really
# it doesn't matter until the fine tuning, which takes awhile.
# 7/15/99: added support if the user selects in pixels (assumes 72 dpi - deal)
# and tuned it a bit more <sjburges@gimp.org>
use Gimp;
use Gimp::Fu;
use Gimp::Util;
# Gimp::set_trace(TRACE_ALL);
$defaultfont = "-*-blippo-heavy-r-normal-*-*-360-*-*-p-*-iso8859-1";
undef $defaultfont;
$calls = 0;
sub growfont {
($fontname, $plussize) = @_;
@fontdesc = split /-/, $fontname;
$fontdesc[8] eq "*" ? ($fontdesc[7] += $plussize/72) : ($fontdesc[8]+= $plussize);
$outname = join "-", @fontdesc;
#print ("!!!${fontdesc[7]}-${fontdesc[8]}!!!\n");
$calls ++;
return $outname;
}
register "fit_text",
"Fit Text - fit text to a selection",
"Have a rectangular selection, and select the font type and spacing. It will fill the selection with text as closely as possible. If no selection is made prior to running, it will fill the entire image.",
"Seth Burgess",
"Seth Burgess <sjburges\@gimp.org>",
"2000-01-29",
N_"<Image>/Filters/Text/Fit Text...",
"*",
[
[PF_FONT, "font", "What font type to use - size will be ignored", $defaultfont],
[PF_STRING, "string", "Text String to fill with", "Fit Text"],
],
sub {
my($img,$layer,$xlfd,$string) =@_;
($sel,$x1,$y1,$x2,$y2) = $img->gimp_selection_bounds;
$width = $x2-$x1;
$height = $y2-$y1;
@extents=Gimp->text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
$growsize = ($extents[0]<$width && $extents[1]<$height) ? 288 : -288;
if ($growsize > 0 ) {
while ($extents[0]<$width && $extents[1]<$height) {
$xlfd = growfont($xlfd,$growsize);
@extents=Gimp->text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
}
$xlfd = growfont($xlfd, -$growsize);
}
else {
while ($extents[0]>$width || $extents[1]>$height) {
$xlfd = growfont($xlfd,$growsize);
@extents=Gimp->text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
}
}
while ($extents[0]<$width && $extents[1]<$height) {
$xlfd = growfont($xlfd,144); # precision for the last bit
@extents=Gimp->text_get_extents_fontname($string,xlfd_size($xlfd),$xlfd);
}
$xlfd = growfont($xlfd, -144);
$tmplay = $layer->text_fontname($x1,$y1,$string,0,1,xlfd_size($xlfd), $xlfd);
$width2=$tmplay->width;
$height2=$tmplay->height;
# X returns crap, so fine tune it here.
# print "$width2, $height2:$width, $height\n";
while ($width2<$width && $height2<$height) {
$tmplay->remove;
$xlfd = growfont($xlfd,288);
$tmplay=$layer->text_fontname($x1,$y1,$string,0,1,xlfd_size($xlfd), $xlfd);
$width2=$tmplay->width;
$height2=$tmplay->height;
}
while ($width2>$width || $height2>$height) {
$tmplay->remove;
$xlfd = growfont($xlfd,-72);
$tmplay=$layer->text_fontname($x1,$y1,$string,0,1,xlfd_size($xlfd), $xlfd);
$width2=$tmplay->width;
$height2=$tmplay->height;
}
while ($width2<$width && $height2<$height) {
$tmplay->remove;
$xlfd = growfont($xlfd,12);
$tmplay=$layer->text_fontname($x1,$y1,$string,0,1,xlfd_size($xlfd), $xlfd);
$width2=$tmplay->width;
$height2=$tmplay->height;
}
$tmplay->remove;
$xlfd = growfont($xlfd,-12);
$tmplay=$layer->text_fontname($x1,$y1,$string,0,1,
xlfd_size($xlfd), $xlfd);
# print $calls;
return();
};
exit main;