freetype
[Top][All Lists]
Advanced

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

[Freetype] Monochrome troubles


From: Paul Tanganelli
Subject: [Freetype] Monochrome troubles
Date: Fri, 03 Jan 2003 19:23:14 -0500

I'm at my wits end here...

I'm trying to render some simple monochrome characters to a single texture to use as the source for my interface character set. Take a look at the attached image to see what I'm shooting for. Everything is working great, except I just can't get the font quality up to par. I've tried just about every combination of load flags in FT_Set_Char_Size, but nothing seems to look good. Zoom in and notice the bulky W and the lopsided 8 for instance. Its 12 point Arial on Win2K.

http://www.imgmag.com/images/mccrankenspank/font_Arial_12_sample.png

Below is a trimmed version of the relevant code I'm using as well. I'm fairly certain that the buffer loading code works just fine since I have routines that print the entire bitmap out to the debug window and the characters directly match the final image I get after loading.


        FT_Int32 nLoadFlags;
        INT32 nCharCount = strlen( TUIFontImage::charMap );
        FT_GlyphSlot pSlot;
        FT_Bitmap* pBitmap;
        FT_Int32 nLoadFlags;

nLoadFlags = FT_LOAD_RENDER | FT_LOAD_MONOCHROME ; // FT_LOAD_MONOCHROME | FT_LOAD_NO_AUTOHINT;

        error = FT_Set_Char_Size( m_pFontFace, 0, m_nFontSize << 6, 96, 96 );
        if ( error )
        {
                // TODO:
        }

        error = FT_Load_Char( m_pFontFace, TUIFontImage::charMap[n] , 
nLoadFlags );
        if (error) continue;  // ignore errors

        pSlot = m_pFontFace->glyph;
        pBitmap =&pSlot->bitmap;

        for ( nY = 0; nY < pBitmap->rows; nY++)
        {
                for ( nX = 0; nX < pBitmap->width; nX++ )
                {
                        readByte = pBitmap->buffer[(nY*pBitmap->pitch) + (nX >> 
3)];

                        nCurIndex = nCharY+nY;
                        nCurIndex *= FONT_TEXTURE_WIDTH << 1;
                        nCurIndex += ( nCharX + nX ) << 1;

                        if ( readByte & ( 0x80 >> (nX & 0x07 ) ) )
                        {
                                loadBuffer[nCurIndex] = (char)0xFF;
                                loadBuffer[nCurIndex+1] = (char)0xFF;   // Full 
opacity
                        }
                        else
                        {
                                loadBuffer[nCurIndex] = (char)0x00;     // 
Color is irrelevant
                                loadBuffer[nCurIndex+1] = (char)0x00;   // zero 
opacity
                        }
                }
        }



Does anyone know a way to get the font resolution in windows? (small fonts (96) / large fonts(120) )

I'm guessing my problem has to do with the loading flags I'm using in FT_Set_Char_Size. Might it have something to do with Hinting being disabled?

Anyway, if someone could take a brief look at things and maybe throw me some advice I'd greatly appreciate it.


        - Paul







_________________________________________________________________
MSN 8: advanced junk mail protection and 2 months FREE*. http://join.msn.com/?page=features/junkmail




reply via email to

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