Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Imager font problem

by Anonymous Monk
on Apr 16, 2024 at 21:04 UTC ( [id://11158903]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm using Imager to render truetype fonts but there is no output, and no error, it's just blank. I checked $Imager::formats{tt} to see if Imager has truetype support and it's blank. I have some /usr/share/fonts/truetype so I dunno why Imager says that. How can Imager be compiled with tt support?

I have another computer with a similar setup but on that one Imager does render truetype even though $Imager::formats{tt} is blank! They are different operating systems and versions of Imager so I don't know. I could install the only fonts that Imager supports on this box: Freetype2, but I want to use truetype and would appreciate any ideas you have on how to get Imager to use my fonts.

Thank you.

Replies are listed 'Best First'.
Re: Imager font problem
by hippo (Bishop) on Apr 17, 2024 at 06:42 UTC
    They are different operating systems and versions of Imager so I don't know.

    It is somewhat surprising that you thought the details here to be of so little relevance that you didn't include them. Oh well.

    any ideas you have on how to get Imager to use my fonts.

    Since you have provided no code at all, perhaps that is where the problem lies? I have just tested align-string.pl with this invocation:

    $ ./align-string.pl /usr/share/fonts/TTF/luxisb.ttf 20 string.png Perl +Monks

    and it has worked flawlessy (after fixing the shebang) on Imager 1.019 here. I suggest you try something similar.


    🦛

Re: Imager font problem
by GrandFather (Saint) on Apr 17, 2024 at 00:07 UTC

    Where is the Perl code that demonstrates the issue?

    What OS and version are you using? Are you using system Perl or a Perl that you have installed? What version of Perl?

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
      Thanks for the replies. Sorry for the confusion. Let me rephrase the question: Why does Imager install on macOS Sonoma without truetype font support, and how can that be enabled? The entire GUI of this computer is rendered with truetype fonts! Does Imager need to update their installer? Relevant code from Imager::Font:
      use Imager; print "Has truetype" if $Imager::formats{tt}; print "Has t1 postscript" if $Imager::formats{t1}; print "Has Win32 fonts" if $Imager::formats{w32}; print "Has Freetype2" if $Imager::formats{ft2};
        macOS Sonoma 14.3 Perl v5.38.2 Imager 1.023:
        perl -e 'use Imager; print "Has truetype" if $Imager::formats{tt}; print "Has t1 postscript" if $Imager::formats{t1}; print "Has Win32 fonts" if $Imager::formats{w32}; print "Has Freetype2" if $Imager::formats{ft2};'
        > Has Freetype2
Re: Imager font problem
by tonyc (Friar) on Apr 18, 2024 at 03:09 UTC

    Unfortunately %formats reflects the libraries more than the formats, especially for fonts.

    The $Imager::formats{tt} entry reflects availability of freetype 1.x, which no modern system should be using. Modern systems should be using Freetype 2.x, which is reflected in the $Imager::formats{ft2} key.

    To enable that when installing Imager itself, you will need to ensure Freetype 2.x and its development headers are installed, this is included with Strawberry perl, and packaged by most Unix-likes (Linux, BSDs, etc).

    If you want to declare a dependency you can depend on Imager::Font::FT2 which will only successfully install if Freetype 2.x is found.

    Some Linux distributions package Imager (Fedora, Debian, Mageia) which might simplify things for you if you're using the system perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11158903]
Approved by GrandFather
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-05-30 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found