[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: KDE Control Center
From: Hans Meine <hans_meine () gmx ! net>
Date: 2001-02-24 21:34:03
[Download RAW message or body]
Alex Zepeda <jazepeda@pacbell.net> writes:
> On Tue, Feb 20, 2001 at 01:18:45PM +0100, Martijn Klingens wrote:
>
> > Including the font with KDE would from our point of view be the best by far
> > (like MS ships Verdana for a while with recent versions now that they use it
> > theirselves) but that also means we have to play with X11 fonts and the like.
> > Worse, I suspect the font to be a TrueType font and afaik only XFree supports
> > that at the moment.
> > I don't think we want to go that way, although it's obviously the best for
> > i18n.
>
> Well.... wouldn't it be possible to convert it to a bitmap font? I
> imagine it doesn't really need to scale. Either way, generating a PNG
> from a script (if not PHP, maybe perl?) would be IMO not such a horrible
> thing to do.
I just put this perlscript together (it's a patched version of something I did
before); it puts a text on an image and creates a shadow layer. Just fiddle with
it - it is even quite well commented. ;-)
+ it uses Gimp's anti-aliasing code
+ it's done and works
Someone could easily configure it and make it work on a number of images I guess.
(To test: just run gimp and select Xtns/Perl/Server to run the perl-gimp interface
server.)
---------------------------------------------------------------------------------
#!/usr/bin/perl
use Gimp;
use Cwd;
# makes param a global filename if it is not
sub make_global {
my ($filename) = @_;
if ($filename !~ m/^\//) {
$filename= cwd()."/".$filename;
}
return $filename;
}
# opens hardcoded template file and writes specified text in specified color
# on it, then save with given filename
sub generate_image {
my ($filename, $text, $color) = @_;
# save palette state
@oldfg= Palette->get_foreground();
@oldbg= Palette->get_background();
# open template file
print "loading '$template_filename'...\n";
$template= make_global($template_filename);
$img= Gimp::file_png_load(1, $template, $template);
$img->set_filename(""); # prevent from accidentally saving over template
# Create text layer
# this could be used to calculate a special text pos
@text_extends= Gimp->text_get_extents_fontname($text, $font_pxsize, Gimp::PIXELS, $x_fontname);
# (now $text_extends[0]=width, [1]=height, [2]=ascent, [3]=descent)
Palette->set_foreground($color);
$text_left= 192;
$text_top= 27-$text_extends[1]+$text_extends[2];
# new layer (-1) antialiased text (1) w/o border (-1)
print "putting '$text' at $text_left/$text_top (size $font_pxsize)...\n";
$textlayer= $img->text_fontname(-1, $text_left, $text_top, $text, -1, 1,
$font_pxsize, Gimp::PIXELS, $x_fontname);
# raise text layer
#$img->raise_layer_to_top($textlayer);
# Create shadow layer
print "copying text to prepare shadow layer...\n";
$shadowlayer= $textlayer->copy(0);
$img->add_layer($shadowlayer, -1);
$shadowlayer->lower_layer();
$shadowlayer->set_preserve_trans(0);
$shadowlayer->plug_in_gauss_iir2(2, 2);
$shadowlayer->translate(3, 3);
$shadowlayer->set_opacity(45);
$img->display_new();
return;
# flatten & save as png
print "saving into $filename...\n";
$img->flatten();
$img->file_png_save($img->active_drawable(), $filename, $filename, 0, 6, 0, 0, 0, 0, 0);
# clean up
$img->delete();
Palette->set_foreground(@oldfg);
Palette->set_background(@oldbg);
}
# MAIN
Gimp::init();
$template_filename= "part1_template.png";
$x_fontname= "-*-arial black-*-*-*-*-*-*-*-*-*-*-*-*";
$font_pxsize= 35;
generate_image("example.jpg", "Example", [0, 0, 0]);
Gimp::end();
---------------------------------------------------------------------------------
--
Ciao, / /
/--/
/ / ANS .,* Hamburg, Germany *,.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic