[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [ft] FreeType artefact
From: |
Buu Hao Tran |
Subject: |
RE: [ft] FreeType artefact |
Date: |
Thu, 27 Sep 2007 14:08:10 +0700 |
I call 2 functions to draw text:
FT_String_Set(font_handle,(const unsigned char*)text);
FT_RenderText(font_handle,ptextsurface,x0,y0,bcenter,dx,dy);
void FT_String_Set( FTDemo_Handle* handle, const unsigned char* string )
{
const unsigned char* p = string;
unsigned long codepoint;
unsigned char in_code;
int expect;
PGlyph glyph = handle->string;
handle->string_length = 0;
codepoint = expect = 0;
while ( *p )
{
in_code = *p++ ;
if ( in_code >= 0xC0 )
{
if ( in_code < 0xE0 ) /* U+0080 -
U+07FF */
{
expect = 1;
codepoint = in_code & 0x1F;
}
else if ( in_code < 0xF0 ) /* U+0800 -
U+FFFF */
{
expect = 2;
codepoint = in_code & 0x0F;
}
else if ( in_code < 0xF8 ) /* U+10000 -
U+10FFFF */
{
expect = 3;
codepoint = in_code & 0x07;
}
continue;
}
else if ( in_code >= 0x80 )
{
--expect;
if ( expect >= 0 )
{
codepoint <<= 6;
codepoint += in_code & 0x3F;
}
if ( expect > 0 )
continue;
expect = 0;
}
else /* ASCII, U+0000 -
U+007F */
codepoint = in_code;
glyph->glyph_index = FTDemo_Get_Index( handle,
codepoint );
glyph++;
handle->string_length++;
if ( handle->string_length >= MAX_GLYPHS )
break;
}
handle->string_reload = 1;
}
void FT_RenderText(FTDemo_Handle *font_handle,XSurface *ptextsurface,const
int &x0,const int &y0,bool bcenter,const int &dx,const int &dy)
{
FTDemo_String_Context sc;
sc.matrix=NULL;
sc.gamma_ramp=NULL;
FT_Matrix mt;
if(bcenter)
{
sc.center=1L<<15;
}
else
{
sc.center=0;
}
sc.vertical=0;
int x=x0;
int y=y0;
FT_Size size;
FTDemo_Get_Size(font_handle,&size);
if(dy)
{
FT_Angle angle=FT_Atan2(dx,dy);
FT_Vector v;
FT_Vector_Unit(&v,angle);
mt.xx=mt.yy=v.x;
mt.xy=v.y;
mt.yx=-v.y;
sc.matrix=&mt;
}
{
FT_BBox glyph_bbox;
FT_Glyph glyphs;
FT_UInt gindex= font_handle->string->glyph_index;
FT_Load_Glyph( size->face, gindex, FT_LOAD_DEFAULT
);
FT_Get_Glyph( size->face->glyph, &glyphs );
FT_Glyph_Get_CBox( glyphs, ft_glyph_bbox_pixels,
&glyph_bbox );
FT_Vector pen1={glyph_bbox.xMin,glyph_bbox.yMin};
FT_Vector pen2={glyph_bbox.xMin,glyph_bbox.yMax};
if(sc.matrix)
{
FT_Vector_Transform(&pen1,sc.matrix);
FT_Vector_Transform(&pen2,sc.matrix);
}
x-=(pen1.x+pen2.x)>>1;
y+=(pen1.y+pen2.y)>>1;
FT_Done_Glyph( glyphs );
}
grBitmap destbmp;
FT_CreateFontDisplay(GetXSurfacebuffer(ptextsurface),GetXSurfacePitch(ptexts
urface),GetXSurfaceWidth(ptextsurface),GetXSurfaceHeight(ptextsurface),&dest
bmp);
ft_display.bitmap=&destbmp;
FT_String_Draw(font_handle,&ft_display,&sc,x,y);
}
XSurface is just pointer to the memory buffer.
Text not zoomed up.
Thanks
-----Original Message-----
From: Werner LEMBERG [mailto:address@hidden
Sent: Tuesday, September 25, 2007 5:28 PM
To: address@hidden
Cc: address@hidden
Subject: Re: [ft] FreeType artefact
> I use FreeType in my application (Windows XP). It seems to work well
> at begining, but after few minutes of using the software text become
> very low quality. You can see bad and good text here:
> http://66.232.119.162/img/fontbug.PNG Please advice what's wrong?
> Same code produce different text quality.
Code snippet, please, which explicitly demonstrates the problem. It's very
unlikely that this is a bug in FreeType...
Werner
- [ft] FreeType artefact, Buu Hao Tran, 2007/09/25
- Re: [ft] FreeType artefact, Werner LEMBERG, 2007/09/25
- RE: [ft] FreeType artefact,
Buu Hao Tran <=
- Re: [ft] FreeType artefact, Werner LEMBERG, 2007/09/27
- RE: Re: [ft] FreeType artefact, Buu Hao Tran, 2007/09/28
- Re: [ft] FreeType artefact, Werner LEMBERG, 2007/09/28
- Re: [ft] FreeType artefact, Dave Williss, 2007/09/28
- [ft] subpixel positioning, Sergey Tolstov, 2007/09/29
- RE: [ft] subpixel positioning, Sergey Tolstov, 2007/09/29
Re: [ft] FreeType artefact, Dave Williss, 2007/09/25