vishnu.prasad has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I want to know whether there is any way to pre-antialiase a given ttf file using perl.. Are there any modules available for that in perl that i can use?? regards.

Replies are listed 'Best First'.
Re: anti aliasing fonts
by BrowserUk (Patriarch) on Jan 06, 2011 at 06:58 UTC
    I want to know whether there is any way to pre-antialiase a given ttf file using perl..

    "Pre-" to what?

    To the best of my knowledge, there is no way to "pre-antialiase a given ttf file". In any language.

    Anti-aliasing involves blending the color of the foreground color (the color the text is to be drawn in), with the background color (the color over which the text is to be drawn), for selected pixels to produce tha appearance of smoother curves and diagonals.

    To "pre-antialias" a font, you would need to know what colors (foreground and background) the font would be drawn n before they were drawn.

    In essence, your question does not make sense. Try explaining why you want to do this and what you hope to achieve by it?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: anti aliasing fonts
by chrestomanci (Priest) on Jan 06, 2011 at 09:18 UTC

    In the general case, no you can't anti alias a ttf font in advance. A ttf (True Type) font, is defined as a vector outline, so the font cannot contain an anti aliased form.

    Anti aliasing happens when the font is rendered to a bitmap output device. The rendering process is specific to the output device, and depends on the resolution and greyscale depth of the output device. Typical anti aliasing is done for low resolution devices with high greyscale depth. (eg computer screens), but not for high resolution devices with low greyscale depth. (eg laser printers).

    Having said all that, If you can explain in more detail what you are trying to do then there may be a solution. For example, on some systems, the font libraries will create and store a cache of font glyphs pre-rendered at common resolutions and grey-scale depths. There are probably ways to pre-populate that cache before it is used.

      i am generating a bitmap from the ttf file using freetype library. The generated bitmap is having greycale values but the rendered font has uneven greyscale even though it is anialiased. Say if it is the letter E then only some parts have a black bord since they have to be anti aliased but the others dont. I want it to look smooth wich it is now but i also want it to look uniform, which it is not.. Is there a solution??

        Details on how a font gliph gets rendered come from the font and your font rendering libary. There is a trade off between readability and aesthetics. In general on windows fonts are rendered for readability, but on Apple computers they are rendered for aesthetics. There are also features of the font that guide how it is rendered such as scaffolding and hinting.

        It sounds to me like you are on a windows computer and are not finding your screen beautiful enough. If you go to your local Apple store and give them $2000, they should be able to help you out. :-)

        Seriously, this question has nothing to do with perl and is out of scope for Perl Monks.

Re: anti aliasing fonts
by Anonymous Monk on Jan 06, 2011 at 06:12 UTC
    any way to pre-antialiase a given ttf file using perl.

    The way I understand it, just like frobnicating the fetzer valve, it cannot be done using perl or java ... anything