paragui-users
[Top][All Lists]
Advanced

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

Re: [paragui-users] Win32 Fonts not drawing


From: Steve McCrea
Subject: Re: [paragui-users] Win32 Fonts not drawing
Date: Wed, 10 Dec 2003 18:56:55 +0100

Another reason fonts might not show up with freetype and paragui - there is no blit to 24 bit surfaces in pgfont.cpp.
Here's a fix (sorry about the formatting):

inline void Blit24(Uint8 *pixels, SDL_Surface* Surface, FT_Bitmap *Bitmap, int PosX, int PosY, int x0, int x1, int y0, int y1, PG_Font *Param)
{
int xw = x1-x0;
SDL_PixelFormat* format = Surface->format;
Uint8 bpp = format->BytesPerPixel;
Uint32 pitch = Surface->pitch;
Uint32 src_pitch = Bitmap->pitch;
register Uint8* src_pixels = Bitmap->buffer + x0 + y0*Bitmap->pitch;
register Uint8* dst_pixels = (Uint8*)pixels + (PosX+x0)*bpp + (PosY+y0)*pitch /*+ Surface->offset*/;
Uint8* line;
// make up the font colour in the surface format
SDL_Color fc = Param->GetColor();
int fontColor = (fc.r<<format->Rshift)|(fc.g<<format->Gshift)|(fc.b<<format->Bshift);
int fc0 = fontColor&0xff;
int fc1 = (fontColor>>8)&0xff;
int fc2 = (fontColor>>16)&0xff;
int alpha = Param->GetAlpha();
line = dst_pixels;
for (register int y = y0; y <y1; y++, src_pixels += src_pitch-xw)
{
dst_pixels = line;
for (register int x = x0; x < x1; x++, dst_pixels += bpp)
{
// get source pixel value
unsigned int v = *src_pixels++;
// don't do anything if the pixel is fully transparent
if (v > 0)
{
if (alpha != 255)
{
v = (v * alpha) >> 8;
}
if (v == 255)
{
// just write it
*dst_pixels = fc0;
*(dst_pixels+1) = fc1;
*(dst_pixels+2) = fc2;
}
else
{
// get the pixel
unsigned int c0 = *dst_pixels;
unsigned int c1 = *(dst_pixels+1);
unsigned int c2 = *(dst_pixels+2);
// blend it
c0 += ((fc0 - c0) * v) >> 8;
c1 += ((fc1 - c1) * v) >> 8;
c2 += ((fc2 - c2) * v) >> 8;
// write it
*dst_pixels = c0;
*(dst_pixels+1) = c1;
*(dst_pixels+2) = c2;
}
}
}
line += pitch;
}
}

and in PG_FontEngine::BlitFTBitmap, in the switch:

case 3:
Blit24((Uint8*)Surface->pixels, Surface, Bitmap, PosX, PosY, x0, x1, y0, y1, Param);
break;
Cheers,
Steve

----- Original Message -----
From: Kirk Haderlie
To: 'address@hidden'
Sent: Tuesday, December 02, 2003 6:45 PM
Subject: RE: [paragui-users] Win32 Fonts not drawing


I managed to figure out why my fonts were not showing up.  When I built freetype I did not uncomment
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
without this you get glyph that have nothing in them.  My bad just unfamiliar with freetype.
-----Original Message-----
From: Kirk Haderlie [mailto:address@hidden
Sent: Wednesday, November 26, 2003 10:32 AM
To: 'address@hidden'
Subject: [paragui-users] Win32 Fonts not drawing


I am trying to get paragui demo 1.04 working compiling with Visual Studio .NET.  I have the demo working but none of the text is being drawn.  I am using freetype 2.1.5.  Anyone every had this problem?  Your help would be appreciated.

Kirk Haderlie
Design Engineer
Vivid Image Technology
address@hidden




_______________________________________________
paragui-users mailing list
address@hidden
http://mail.nongnu.org/mailman/listinfo/paragui-users

reply via email to

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