freetype
[Top][All Lists]
Advanced

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

Re: [Freetype] freetype newbie


From: graham
Subject: Re: [Freetype] freetype newbie
Date: Thu, 15 Aug 2002 12:54:32 -0400

Wow!  This got me much further along than before.  Thanks so much. 
Now I can change the sizes and stuff and it works.

Thanks!

- Graham


---- Original Message ----
From: address@hidden
To: address@hidden, address@hidden
Subject: Re: [Freetype] freetype newbie
Date: Thu, 15 Aug 2002 09:40:30 +0200 (CEST)

>
> Hi Graham,
>
> I just went through the same sort of problems you encounter now. The
>doc
>is helpful but a very simple example is missing. The standard demo
>programs work well (so like that we know the the FT_ library is
>working,
>after having fight with for some times we can have doubts :-)), but
>they
>are a bit too complex to be use as starting point to write an
>application.
>I finally succeed to render some text thanks to people (Michael, and
>Derek) in this mailing list. 
>
>So here are the point I encountered difficulties with. As you do not
>use
>AA I suppose you render your glyph with something like:
>
>FT_GlyphSlot slot = face->glyph;
>error = FT_Get_Glyph ( slot, &glyph );
>FT_Glyph_To_Bitmap( &glyph, ft_render_mode_mono, 0, 1 );
>
>
>Then the important values to render it are:
>
>FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
>FT_Bitmap*     source = &bitmap->bitmap;
>
>Width   = source->width;
>Height  = source->rows;
>Pitch   = source->pitch;
>Bitmap  = source->buffer;
>Descent = int(TTCeil(slot->metrics.height -
>slot->metrics.horiBearingY) >> 6);
>Ascent  = source->rows - c->fDescent;
>Xoff    = int(slot->metrics.horiBearingX >> 6);
>
>
>Then the rendering in the X11 bitmap:
>
>char d = 0, *s = Bitmap;
>char* row=s;
>for (int y = 0; y < (int)Height; y++) {
>int n = 0;
>s = row;
>for (int x = 0; x < (int)Width; x++) {
>   if (n == 0) d = *s++;
>   if (TESTBIT(d,7-n))
>      XPutPixel(xim, bx + c->fXoff + x, by - c->fAscent + y, fore);
>      if (++n == (int) 8) n = 0;
>   }
>   row += Pitch;
>}
>
>
>I work in C++. I have also:
>
>inline long TTCeil(Long_t x) { return (x + 63) & -64; }
>
>and
>
>#define BIT(n)       (1 << (n))
>#define TESTBIT(n,i) ((bool)(((n) & BIT(i)) != 0))
>
>I hope that will help you and that I have not forget anything.
>
> Cheers,        Olivier





reply via email to

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