I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-06-12 02:05:32-07 by actan
What turetype font can draw Greek letters (alpha, beta, lambda) on images?
Hi there, I listed all ttf fonts on my machine and tried a lot of fonts, but I just can't dispaly these Greek letters correctly. I tried DejaVuSansMono.ttf, tahoma.ttf ... My perl code file is encoded in utf-8, I just write these letter in it, and they can be displayed on console without any problem. But I just want to draw it on some images. And I think this is a font issue .... Anyone can tell me which ttf font supports Greek letters? I even can't paste them in this post ... Thanks in advance!
Direct Responses: 10953 | Write a response
Posted on 2009-06-12 05:10:22-07 by tonyc in response to 10952
Re: What turetype font can draw Greek letters (alpha, beta, lambda) on images?

Without seeing your code, it's hard to see. The DejaVuSansMono.ttf from Debian certainly supports greek:

#!perl -w use strict; use Imager; # no greek support in ImUgly.ttf #my $fontfile = "fontfiles/ImUgly.ttf"; my $fontfile = "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/DejaVuSansMono.ttf"; my $font = Imager::Font->new(file => $fontfile, aa => 1) or die "Cannot open font file $fontfile: ", Imager->errstr, "\n"; my $text = chr(0x3a3); # GREEK CAPITAL LETTER SIGMA my $im = Imager->new(xsize => 100, ysize => 50); $im->align_string ( x => 50, y => 25, halign => "center", valign => "center", font => $font, size => 40, color => '#FFF', string => $text ) or die $im->errstr; $im->write(file => "utf8text.ppm") or die "Cannot write utf8text.ppm:", $im->errstr, "\n";

You also don't say what results you get when you attempt to output greek text, I'd suspect an encoding issue if you're seeing apparently random text.

If you are seeing random text, it's possible you need to either mark the text as utf8, or tell Imager that the text is utf8, by supplying utf8 => 1 to the align_string() call.

I also did a test with use utf8; and setting $text to a literal sigma inline, this worked for me.

Direct Responses: 10956 | Write a response
Posted on 2009-06-12 08:36:51-07 by actan in response to 10953
Re: What turetype font can draw Greek letters (alpha, beta, lambda) on images?
Thank you, tony! Problem fixed! ^-^
Direct Responses: Write a response