freetype
[Top][All Lists]
Advanced

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

[ft] Help with making sure all characters fit in Certain pixel dimension


From: Shomari Sharpe
Subject: [ft] Help with making sure all characters fit in Certain pixel dimensions
Date: Thu, 25 Jun 2015 16:10:06 -0500

Hi,
I'm creating an font system that uses bitmap fonts generated from freetype to be used in my game engine. It appears that even though I have specified a pixel size of 64px there are characters that are rendered outside the actual pixel size I have specified though the actual FT_Face->Glyph->Bitmap is actually smaller the 64px. There also seems to be a big gap of approximately 12px above glyphs. Below is the code I am using for placement on a flat bitmap.

------------------------------------- CODE -----------------------------------------
font_size = 64;

        /* convert to an anti-aliased bitmap */
        FT_Render_Glyph( freetype_face->glyph, FT_RENDER_MODE_LCD );

        //This reference will make accessing the bitmap easier
        FT_Bitmap& bitmap=freetype_face->glyph->bitmap;
       
for (int y = 0; y < bitmap.rows; y++)
            for (int x = 0; x < bitmap.width; x++)
            {
                pixel_t pixel = { 0, 0, 0, bitmap.buffer[bi]};
                putpixel((xoffset+x), (yoffset+y+ font_size-abs(freetype_face->glyph->bitmap_top)), maxwidth, fontdata, pixel);
                bi++;
            }
xoffset += bitmap.width;

---------------------------------- END CODE ------------------------------------

I've included a sample png image showing the results. Help please?


Regards,
Shomari Sharpe

Attachment: test.png
Description: PNG image


reply via email to

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