freetype
[Top][All Lists]
Advanced

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

[ft] Freetype stroke


From: Kuon
Subject: [ft] Freetype stroke
Date: Fri, 28 Dec 2007 15:13:21 +0100

Greetings,

I am currently using freetype as font renderer in the game I am working on.

I use the code you will find at the end of this email.

This works fine.

Now, I want a stroke around the glyphs (of n pixel wide, where n is a float). I could put it in the red channel for example (so I can use it in GL fragment shader later to do whatever I want).

I checked the documentation, but I got a little bit lost.


Any pointer appreciated.

Best regards

--
kuon

http://kuon.goyman.com
http://goyman.com



static void
loadAndRenderGlyph (FontGlyph glyph)
{
        unsigned error;
        int i, j;
        FT_GlyphSlot ftFontGlyph;
        FT_Bitmap *bitmap;

error = FT_Load_Glyph (glyph->font->ftFontFace, glyph->index, FT_LOAD_RENDER);

        if (error)
                log_fatal ("Unable to load and render glyph at index 0x%X in 
%s.",
                           glyph->index, glyph->font->ftFontFace->family_name);

        /* Copy the FT glyph info into our glyph. */
        ftFontGlyph = glyph->font->ftFontFace->glyph;

        /* Copy metrics */
        glyph->advance = ftFontGlyph->advance.x >> 6;
        glyph->xBearing = ftFontGlyph->bitmap_left;
        glyph->yBearing = ftFontGlyph->bitmap_top;


        bitmap = &glyph->font->ftFontFace->glyph->bitmap;

        /* Prepare image */
        glyph->w = ftFontGlyph->bitmap.width;
        glyph->h = ftFontGlyph->bitmap.rows;
glyph->pixels = calloc (bitmap->rows * bitmap->width, sizeof (*glyph- >pixels));

        /* Copy data */

        for (i = 0; i < bitmap->rows; i++)
                for (j = 0; j < bitmap->width; j++)
#if BYTE_ORDER == BIG_ENDIAN
                        glyph->pixels[i * bitmap->width + j] =
                                0xFFFFFF00 | bitmap->buffer[(bitmap->rows - i - 
1) *
                                                            bitmap->pitch + j];
#else
                        glyph->pixels[i * bitmap->width + j] =
                                0x00FFFFFF | bitmap->buffer[(bitmap->rows - i - 
1) *
                                                            bitmap->pitch + j] 
<< 24;
#endif
}




reply via email to

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