freetype
[Top][All Lists]
Advanced

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

Re: [ft] Problem in rotating the text


From: harshagomes
Subject: Re: [ft] Problem in rotating the text
Date: Tue, 5 May 2009 01:16:20 -0700 (PDT)

here's the code snippet...

//the string value
char *nm = "robinhood ln";

//rotating angle
angle = atan( slope ); // the value here roughly comes around 1.07 radians..

//drawing loop
while( nm[i] != '\0' ) 
{
       //set up matrix
       matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
       matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
       matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
       matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );

       //set transformation 
       FT_Set_Transform( face, &matrix, &pen );
       
       fterror = FT_Load_Char( face, (unsigned long)nm[i], FT_LOAD_RENDER ); 
       
       //drawing function     
       color = draw_bitmap( &slot->bitmap, slot->bitmap_left, gb->height -
slot->bitmap_top, gb ); 
       pen.x += slot->advance.x;
       pen.y += slot->advance.y;

       i++; 
}

//drawing function definition
DWORD LabelDraw::draw_bitmap( FT_Bitmap*  bitmap, int x, int y, 
                              GraphicsBuffer *gb )
{
    int  i, j, p, q;
    int  x_max = x + bitmap->width;
    int  y_max = y + bitmap->rows;

    BYTE red,green,blue,alpha;
    DWORD dwTextColor = 0; 

    if( g->gs->mv->draw->mode == kDayMode )
        red = green = blue = 0;
    else
        red = green = blue = 255;

    for ( i = x, p = 0; i < x_max; i++, p++ )
    {
        for ( j = y, q = 0; j < y_max; j++, q++ )
        {
            if ( i < 0      || j < 0       ||
                i >= gb->width || j >= gb->height )
                continue;
            else
            { 
                alpha = bitmap->buffer[q * bitmap->width + p]; //& 0x00ff;
                dwTextColor = MAKELONG( MAKEWORD(blue,green),
MAKEWORD(red,alpha) );
                gb->labelLayer->set( dwTextColor, j * gb->width + i );
            }
        }
    }
    return dwTextColor;
}


i try to calculate the 'slope' based on the line's (on which the text needs
to be drawn) start and end points.. 




Werner LEMBERG wrote:
> 
> 
>>     if i try to apply the transformation using the matrix to rotate
>> the text, am not able to get the characters clear at certain
>> angles...
>> 
>> for instance, at certain angles, the text appears crumpled as shown
>> below...
>> 
>> http://www.nabble.com/file/p23380999/samp.jpg 
> 
> Sample code, please.
> 
> 
>     Werner
> 
> 
> _______________________________________________
> Freetype mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/freetype
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Problem-in-rotating-the-text-tp23380999p23383018.html
Sent from the Freetype - User mailing list archive at Nabble.com.





reply via email to

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