freetype
[Top][All Lists]
Advanced

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

[ft] FT_LOAD_TARGET_LCD


From: Tom Brinkman
Subject: [ft] FT_LOAD_TARGET_LCD
Date: Sat, 14 Apr 2007 16:41:07 -0700

Im having trouble creating "cleartype" quality fonts.  I've read the docs and
need to know how the freetype buffer is packed so I can extract the red,green and blues.

The index of the non-cleartype gray buffer from the example on the "freetype" website is:
row*slot->bitmap.width + col

The buffer is packed differently the flag "FT_LOAD_TARGET_LCD" is set.
It states in the documentation that the width of the buffer is multiplied by three.
How do index that buffer?

Example:

FT_Load_Char(face, 'A', FT_LOAD_RENDER|FT_LOAD_TARGET_LCD);

int width = face->glyph->metrics.width >> 6;
int height =face->glyph->metrics.height >> 6;
int x = 0;
int y = 0;

for (int xpos = x, col = 0; xpos < (x+width); xpos++, col++ )
    for (int ypos = y, row = 0; ypos < (y+height); ypos++, row++ )
    {
        int index = row*slot->bitmap.width + col;
        int red = (int)slot->bitmap.buffer[index];
        int green = (int)slot->bitmap.buffer[index];
        int blue = (int)slot->bitmap.buffer[index];        
        printf("%d,%d,%d\n",red,green,blue);
    }


reply via email to

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