freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] Sub-pixel font


From: David Turner
Subject: Re: [Devel] Sub-pixel font
Date: Sat, 23 Nov 2002 15:59:46 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826

Nicholas Liew wrote:
Hiya,

I am writting software to render text on LCD screen. How can I obtain sub-pixel font using the FreeType APIs ?

Well, you'll need to use FreeType, and perform some work yourself as well.

A. Do it yourself:

  * load a hinted glyph outline by calling FT_Load_Glyph, using
    FT_LOAD_TARGET_LCD or FT_LOAD_TARGET_MONO to specify to the
    hinter that you're going to display the glyph on a LCD
    (both flags work). Use FT_LOAD_NO_BITMAP to be certain to not
    load embedded bitmaps.

  * transform it, by applying a 3x scale in the horizontal dimension
    after the glyph was loaded.

  * render it to a 8-bit anti-aliased bitmap. The result is the
    corresponding RGB glyph image to use later.

  * you'll probably need to filter the result to reduce color bleeding
    before sending the bitmap to the screen. You basically need three
    independent R,G,B filters. Read the ClearType litterature and
    the libXft/libXft2 source codes for more information and examples,
    I'm not going to detail this here !!

  * now, compose the image on your screen. You basically need to
    use each independent R,G,B "gray" value as an _independent_
    alpha channel to use during the composition. In other words,
    your composition code should look like:

       dst.r += (src.r - dst.r) * alpha.r;
       dst.g += (src.g - dst.g) * alpha.g;
       dst.b += (src.b - dst.b) * alpha.b;

    instead of:

       dst.r += (src.r - dst.r) * alpha;
       dst.g += (src.g - dst.g) * alpha;
       dst.b += (src.b - dst.b) * alpha;

    this is *not* done by FreeType, because its imply isn't a graphics
    library. There are also chances that your favorite graphics lib
    doesn't support this kind of composition natively, so you'll need
    to code this thing by hand. See "graph/gblit.c" in the ""ft2demos"
    CVS module for functions that do this.

B.Have FreeType do more things for you:

 * call FT_Load_Glyph with (FT_LOAD_TARGET_LCD | FT_LOAD_RENDER), and
   the result (if you didn't forget FT_LOAD_NO_BITMAP) will be an RGB
   8-bit "graymap" as described above (the 3x transform is applied
   automatically by the font engine, how sweet).

 * as before, filter, then compose...

Hope this helps,

- David Turner
- The FreeType Project  (www.freetype.org)





Your kind reply is very much appreciated.

Nicholas

_______________________________________________
Devel mailing list
address@hidden
http://www.freetype.org/mailman/listinfo/devel






reply via email to

[Prev in Thread] Current Thread [Next in Thread]