(none) imager-devel
/ help / lists / applications / search /
 

Re: Imager and Arial Unicode question

From: Tony Cook (
07874@xyz.molar.is)
Date: Wed 16 Apr 2003 - 12:43:24 GMT

  • Next message: Jean-Michel Hiver: "BUG? Trying to use a non existent font"

    On Wed, Apr 16, 2003 at 11:06:24AM +0100, Jean-Michel Hiver wrote:
    > Hi List,
    >
    > I discovered imager on CPAN and I am trying to get it to produce images
    > from unicode text using microsoft's arial unicode font. However it
    > doesn't seem to work :(
    >
    > As a test I am trying to render a UTF-8 string that has ONE accent in it
    > - and it's the only character that doesn't get rendered properly.
    >
    > Attached my very simple test script and the output which is produced.
    > FYI, I use Perl 5.8.0.
    >
    > Thanks in advance for your help!
    > Cheers,

    Which font libraries do you have installed?

    The last release of Imager (0.41) only supported UTF-8 with the freetype 2
    driver. Current CVS supports (or at least decodes UTF-8) for all but the
    Win32 driver.

    By default, the FT1.x driver is used, so UTF-8 isn't understood under
    Imager 0.41, you can override this by either changing the priorities
    of the different drivers, or by explicitly providing a particular font
    type.

    To set the priorities, call the priorities() class method on
    Imager::Font with a list of drivers:

      Imager::Font->priorities(qw(ft2 ft tt));

    To name a specific driver:

      my $font = new Imager::Font
          file => '...',
          color => $black,
          size => 20,
          type => 'ft2'
          or die Imager->errstr;

    Once I did either of these the text was printed with accents.

    Also, since you're source string is internall treated as UTF-8 by
    perl, you don't need to use encode() to convert it to UTF-8, Imager
    will see perl's UTF-8 flag on the string and process it as UTF-8.

    TonY



  •