use strict; use warnings; use utf8; use Imager; my $im = Imager -> new( xsize => 400, ysize => 200 ) -> box( filled => 1, color => 'white' ) -> to_paletted( make_colors => 'mono' ); my $text = 'JORDBÆR PÅ FLØDE (jordbær på fløde)'; my $y = 50; $im-> string( x => 50, y => $y += 25, string => $text, font => $_, color => 'black', size => 16 ) for map { Imager::Font-> new( file => $_, type => 'ft2' ) or die Imager-> errstr } ( 'unifont-10.0.06.ttf', 'ucs-fonts/6x9.bdf', 'ucs-fonts/6x12.bdf', 'ucs-fonts/8x13.bdf', ); $im-> write( file => 'test.png' );

Wikipedia says, the original Unifont was bitmapped font 16 px high. Looks like vectorized to TTF with pixels literally becoming squares (united to rectangles where possible). So rendering, without AA, to any size other than 16, 32, 48, ... will not likely be pretty, especially to smaller sizes (try changing size, above).

You can experiment with other TTF fonts and check if all required (now and in the future ;-) ) glyphs render w/o AA without ugly artifacts at chosen height. It's not totally impossible.

Maybe better go with bitmapped fonts. Note: these are monospaced, + different sizes differ in Unicode coverage. 'Size' parameter appears to be ignored by Imager. + Complex glyphs are also not very beautiful at small sizes.


In reply to Re: Tiny font by vr
in thread Tiny font by oha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.